A wrapper for regcomp() that logs an error message if the regcomp() failed
and uses a return value according to the paraslash rules. Currently there is
only one user of regular expressions, is_v4_dot_quad(), which is converted
to para_regex(), but new callers will be added soon.
Unfortunately, this change made it necessary to include regex.h in all .c files
that use string.h. Clean up the order in which headers are included a bit while
we're at it.
Maybe I should rethink the rule "Only .c files shall include header files"...
65 files changed:
/** \file aac_afh.c para_server's aac audio format handler */
/** \file aac_afh.c para_server's aac audio format handler */
#include <osl.h>
#include "para.h"
#include <osl.h>
#include "para.h"
/** \file aacdec_filter.c paraslash's aac (m4a) decoder. */
/** \file aacdec_filter.c paraslash's aac (m4a) decoder. */
#include "list.h"
#include "sched.h"
#include "ggo.h"
#include "list.h"
#include "sched.h"
#include "ggo.h"
/** \file acl.c Access control lists for paraslash senders. */
/** \file acl.c Access control lists for paraslash senders. */
#include "para.h"
#include "error.h"
#include "string.h"
#include "para.h"
#include "error.h"
#include "string.h"
/** \file afh.c Paraslash's standalone audio format handler tool. */
/** \file afh.c Paraslash's standalone audio format handler tool. */
#include <dirent.h>
#include <sys/time.h>
#include <dirent.h>
#include <sys/time.h>
#include <sys/time.h> /* gettimeofday */
#include <sys/types.h>
#include <dirent.h>
#include <sys/time.h> /* gettimeofday */
#include <sys/types.h>
#include <dirent.h>
#include "para.h"
#include "error.h"
#include "para.h"
#include "error.h"
/** \file afs.c Paraslash's audio file selector. */
/** \file afs.c Paraslash's audio file selector. */
#include <signal.h>
#include <fnmatch.h>
#include <openssl/rc4.h>
#include <signal.h>
#include <fnmatch.h>
#include <openssl/rc4.h>
/** \file aft.c Audio file table functions. */
/** \file aft.c Audio file table functions. */
#include <dirent.h> /* readdir() */
#include <openssl/rc4.h>
#include <dirent.h> /* readdir() */
#include <openssl/rc4.h>
+#include <sys/mman.h>
+#include <fnmatch.h>
+#include <sys/shm.h>
#include "para.h"
#include "error.h"
#include "crypt.h"
#include "string.h"
#include "para.h"
#include "error.h"
#include "crypt.h"
#include "string.h"
-#include <sys/mman.h>
-#include <fnmatch.h>
-#include <sys/shm.h>
-
#include "afh.h"
#include "afs.h"
#include "net.h"
#include "afh.h"
#include "afs.h"
#include "net.h"
* based on the vplay program by Michael Beck.
*/
* based on the vplay program by Michael Beck.
*/
#include <sys/types.h>
#include <dirent.h>
#include <alsa/asoundlib.h>
#include <sys/types.h>
#include <dirent.h>
#include <alsa/asoundlib.h>
/** \file amp_filter.c Paraslash's amplify filter. */
/** \file amp_filter.c Paraslash's amplify filter. */
#include "para.h"
#include "amp_filter.cmdline.h"
#include "list.h"
#include "para.h"
#include "amp_filter.cmdline.h"
#include "list.h"
/** \file attribute.c Attribute handling functions. */
/** \file attribute.c Attribute handling functions. */
#include <openssl/rc4.h>
#include <osl.h>
#include <openssl/rc4.h>
#include <osl.h>
/** \file audioc.c the client program used to connect to para_audiod */
/** \file audioc.c the client program used to connect to para_audiod */
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
*/
/** \file audiod.c the paraslash's audio daemon */
*/
/** \file audiod.c the paraslash's audio daemon */
#include <sys/types.h>
#include <dirent.h>
#include <signal.h>
#include <sys/types.h>
#include <dirent.h>
#include <signal.h>
/** \file audiod_command.c commands for para_audiod */
/** \file audiod_command.c commands for para_audiod */
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
#include "ggo.h"
#include "filter.h"
#include "grab_client.h"
#include "ggo.h"
#include "filter.h"
#include "grab_client.h"
#include "error.h"
#include "audiod.h"
#include "net.h"
#include "error.h"
#include "audiod.h"
#include "net.h"
/** \file blob.c Macros and functions for blob handling. */
/** \file blob.c Macros and functions for blob handling. */
#include <fnmatch.h>
#include <openssl/rc4.h>
#include <osl.h>
#include <fnmatch.h>
#include <openssl/rc4.h>
#include <osl.h>
/** \file chunk_queue.c Queuing functions for paraslash senders. */
/** \file chunk_queue.c Queuing functions for paraslash senders. */
#include "para.h"
#include "list.h"
#include "afh.h"
#include "para.h"
#include "list.h"
#include "afh.h"
/** \file client.c the client program used to connect to para_server */
/** \file client.c the client program used to connect to para_server */
#include <openssl/rc4.h>
#include "para.h"
#include <openssl/rc4.h>
#include "para.h"
/** \file client_common.c Common functions of para_client and para_audiod. */
/** \file client_common.c Common functions of para_client and para_audiod. */
#include <sys/types.h>
#include <dirent.h>
#include <openssl/rc4.h>
#include <sys/types.h>
#include <dirent.h>
#include <openssl/rc4.h>
*/
/** \file close_on_fork.c Manage a list of fds that should be closed on fork. */
*/
/** \file close_on_fork.c Manage a list of fds that should be closed on fork. */
#include "para.h"
#include "list.h"
#include "string.h"
#include "para.h"
#include "list.h"
#include "string.h"
/** \file command.c Client authentication and server commands. */
/** \file command.c Client authentication and server commands. */
#include <signal.h>
#include <sys/time.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/types.h>
* Uses ideas of AudioCompress, (C) 2002-2004 M. Hari Nezumi <magenta@trikuare.cx>
*/
* Uses ideas of AudioCompress, (C) 2002-2004 M. Hari Nezumi <magenta@trikuare.cx>
*/
#include "para.h"
#include "compress_filter.cmdline.h"
#include "list.h"
#include "para.h"
#include "compress_filter.cmdline.h"
#include "list.h"
/** \file crypt.c openssl-based RSA encryption/decryption routines */
/** \file crypt.c openssl-based RSA encryption/decryption routines */
#include <dirent.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/socket.h>
*/
/** \file daemon.c Some helpers for programs that detach from the console. */
*/
/** \file daemon.c Some helpers for programs that detach from the console. */
-#include "para.h"
-#include "daemon.h"
#include <pwd.h>
#include <sys/types.h> /* getgrnam() */
#include <grp.h>
#include <pwd.h>
#include <sys/types.h> /* getgrnam() */
#include <grp.h>
+#include "para.h"
+#include "daemon.h"
#include "string.h"
#include "color.h"
#include "string.h"
#include "color.h"
* (C) 2005 Ian McDonald <imcdnzl@gmail.com>
*/
* (C) 2005 Ian McDonald <imcdnzl@gmail.com>
*/
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
* (C) 2005 Ian McDonald <imcdnzl@gmail.com>
*/
* (C) 2005 Ian McDonald <imcdnzl@gmail.com>
*/
#include <sys/types.h>
#include <dirent.h>
#include <osl.h>
#include <sys/types.h>
#include <dirent.h>
#include <osl.h>
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(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") \
*/
/** \file exec.c Helper functions for spawning new processes. */
*/
/** \file exec.c Helper functions for spawning new processes. */
#include "para.h"
#include "close_on_fork.h"
#include "error.h"
#include "para.h"
#include "close_on_fork.h"
#include "error.h"
/**
* Spawn a new process and redirect fd 0, 1, and 2.
/**
* Spawn a new process and redirect fd 0, 1, and 2.
/** \file fade.c A volume fader and alarm clock for linux. */
/** \file fade.c A volume fader and alarm clock for linux. */
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
-
-#include "fade.cmdline.h"
-#include "para.h"
-#include "fd.h"
-
#include <sys/ioctl.h>
#include <ctype.h>
#include <stdlib.h> /* EXIT_SUCCESS */
#include <sys/ioctl.h>
#include <ctype.h>
#include <stdlib.h> /* EXIT_SUCCESS */
#include <string.h>
#include <limits.h>
#include <sys/soundcard.h>
#include <string.h>
#include <limits.h>
#include <sys/soundcard.h>
+
+#include "fade.cmdline.h"
+#include "para.h"
+#include "fd.h"
#include "string.h"
#include "error.h"
#include "string.h"
#include "error.h"
INIT_FADE_ERRLISTS;
struct fade_args_info conf;
INIT_FADE_ERRLISTS;
struct fade_args_info conf;
/** \file fd.c Helper functions for file descriptor handling. */
/** \file fd.c Helper functions for file descriptor handling. */
#include <sys/types.h>
#include <dirent.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/mman.h>
#include "para.h"
#include "error.h"
#include "string.h"
#include "para.h"
#include "error.h"
#include "string.h"
/**
* Write a buffer to a file descriptor, re-write on short writes.
*
/**
* Write a buffer to a file descriptor, re-write on short writes.
*
#include "para.h"
#include "error.h"
#include "para.h"
#include "error.h"
/** \file fecdec_filter.c A filter fec-decodes an audio stream. */
/** \file fecdec_filter.c A filter fec-decodes an audio stream. */
#include <dirent.h>
#include "para.h"
#include "error.h"
#include <dirent.h>
#include "para.h"
#include "error.h"
/** \file file_write.c simple output plugin for testing purposes */
/** \file file_write.c simple output plugin for testing purposes */
#include <sys/types.h>
#include <dirent.h>
#include <sys/time.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/time.h>
/** \file filter.c The stand-alone filter program. */
/** \file filter.c The stand-alone filter program. */
#include "filter.cmdline.h"
#include "list.h"
#include "sched.h"
#include "filter.cmdline.h"
#include "list.h"
#include "sched.h"
/** \file filter_common.c Common helper functions for filter input/output. */
/** \file filter_common.c Common helper functions for filter input/output. */
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
* \sa filter_chain filter_chain_info filter.
*/
* \sa filter_chain filter_chain_info filter.
*/
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
/** \file gui.c Curses-based interface for paraslash. */
/** \file gui.c Curses-based interface for paraslash. */
#include <signal.h>
#include <sys/types.h>
#include <dirent.h>
#include <signal.h>
#include <sys/types.h>
#include <dirent.h>
#include "gui.cmdline.h"
#include "para.h"
#include "gui.h"
#include "string.h"
#include "gui.cmdline.h"
#include "para.h"
#include "gui.h"
#include "string.h"
#include "ringbuffer.h"
#include "fd.h"
#include "error.h"
#include "ringbuffer.h"
#include "fd.h"
#include "error.h"
/** \file http_recv.c paraslash's http receiver */
/** \file http_recv.c paraslash's http receiver */
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
/** \file http_send.c paraslash's http sender */
/** \file http_send.c paraslash's http sender */
#include <sys/types.h>
#include <dirent.h>
#include <osl.h>
#include <sys/types.h>
#include <dirent.h>
#include <osl.h>
/** \file mood.c Paraslash's mood handling functions. */
/** \file mood.c Paraslash's mood handling functions. */
#include <fnmatch.h>
#include <osl.h>
#include <fnmatch.h>
#include <osl.h>
#include "para.h"
#include "error.h"
#include "string.h"
#include "para.h"
#include "error.h"
#include "string.h"
* Johannes Overmann <overmann@iname.com>
*/
* Johannes Overmann <overmann@iname.com>
*/
#include "para.h"
#include "error.h"
#include "afh.h"
#include "para.h"
#include "error.h"
#include "afh.h"
/** \file mp3dec_filter.c Paraslash's mp3 decoder. */
/** \file mp3dec_filter.c Paraslash's mp3 decoder. */
+#include <mad.h>
+#include <regex.h>
+
#include "para.h"
#include "mp3dec_filter.cmdline.h"
#include "list.h"
#include "para.h"
#include "mp3dec_filter.cmdline.h"
#include "list.h"
#include "ggo.h"
#include "filter.h"
#include "error.h"
#include "ggo.h"
#include "filter.h"
#include "error.h"
#include "string.h"
/** Convert a sample value from libmad to a signed short. */
#include "string.h"
/** Convert a sample value from libmad to a signed short. */
- 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;
result = regexec(&r, address, 0, NULL, 0) == 0;
regfree(&r);
return result;
*/
/** \file ogg_afh.c para_server's ogg vorbis audio format handler */
*/
/** \file ogg_afh.c para_server's ogg vorbis audio format handler */
#include <inttypes.h>
#include <ogg/ogg.h>
#include <vorbis/codec.h>
#include <inttypes.h>
#include <ogg/ogg.h>
#include <vorbis/codec.h>
/** \file oggdec_filter.c Paraslash's ogg vorbis decoder. */
/** \file oggdec_filter.c Paraslash's ogg vorbis decoder. */
+#include <regex.h>
+#include <vorbis/vorbisfile.h>
#include "oggdec_filter.cmdline.h"
#include "list.h"
#include "sched.h"
#include "oggdec_filter.cmdline.h"
#include "list.h"
#include "sched.h"
#include "error.h"
#include "string.h"
#include "error.h"
#include "string.h"
-#include <vorbis/vorbisfile.h>
-
/** Determine byte sex. */
#ifdef WORDS_BIGENDIAN
#define ENDIAN 1
/** Determine byte sex. */
#ifdef WORDS_BIGENDIAN
#define ENDIAN 1
/** \file oss_write.c Paraslash's oss output plugin. */
/** \file oss_write.c Paraslash's oss output plugin. */
#include <sys/ioctl.h>
#include <fcntl.h>
#include <dirent.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <dirent.h>
* Licensed under the GPL v2. For licencing details see COPYING.
*/
* Licensed under the GPL v2. For licencing details see COPYING.
*/
#include "para.h"
#include "error.h"
#include "string.h"
#include "para.h"
#include "error.h"
#include "string.h"
/** \file prebuffer_filter.c Paraslash's prebuffering filter. */
/** \file prebuffer_filter.c Paraslash's prebuffering filter. */
#include "para.h"
#include "prebuffer_filter.cmdline.h"
#include "list.h"
#include "para.h"
#include "prebuffer_filter.cmdline.h"
#include "list.h"
/** \file recv.c the stand-alone audio stream receiver */
/** \file recv.c the stand-alone audio stream receiver */
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
/** \file recv_common.c common functions of para_recv and para_audiod */
/** \file recv_common.c common functions of para_recv and para_audiod */
#include "list.h"
#include "sched.h"
#include "ggo.h"
#include "list.h"
#include "sched.h"
#include "ggo.h"
/** \file ringbuffer.c Simple ringbuffer implementation */
/** \file ringbuffer.c Simple ringbuffer implementation */
#include "para.h"
#include "ringbuffer.h"
#include "string.h"
#include "para.h"
#include "ringbuffer.h"
#include "string.h"
/** \file sched.c Paraslash's scheduling functions. */
/** \file sched.c Paraslash's scheduling functions. */
#include <dirent.h> /* readdir() */
#include <assert.h>
#include <sys/time.h>
#include <dirent.h> /* readdir() */
#include <assert.h>
#include <sys/time.h>
*/
/** \file score.c Scoring functions to determine the audio file streaming order. */
*/
/** \file score.c Scoring functions to determine the audio file streaming order. */
#include "para.h"
#include "error.h"
#include "string.h"
#include "para.h"
#include "error.h"
#include "string.h"
/** \file send_common.c Functions used by more than one paraslash sender. */
/** \file send_common.c Functions used by more than one paraslash sender. */
#include <dirent.h>
#include <osl.h>
#include <dirent.h>
#include <osl.h>
#include "para.h"
#include "error.h"
#include "string.h"
#include "para.h"
#include "error.h"
#include "string.h"
#include <dirent.h>
#include <sys/time.h>
#include <openssl/rc4.h>
#include <dirent.h>
#include <sys/time.h>
#include <openssl/rc4.h>
#include <osl.h>
#include "para.h"
#include <osl.h>
#include "para.h"
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
#include <dirent.h> /* readdir() */
#include <assert.h>
#include <dirent.h> /* readdir() */
#include <assert.h>
#include "list.h"
#include "sched.h"
#include "fd.h"
#include "list.h"
#include "sched.h"
#include "fd.h"
#include <assert.h>
#include "para.h"
#include <assert.h>
#include "para.h"
#include "list.h"
#include "sched.h"
#include "fd.h"
#include "list.h"
#include "sched.h"
#include "fd.h"
/** \file string.c Memory allocation and string handling functions. */
/** \file string.c Memory allocation and string handling functions. */
-#include "para.h"
-#include "string.h"
-
#include <sys/time.h> /* gettimeofday */
#include <pwd.h>
#include <sys/utsname.h> /* uname() */
#include <string.h>
#include <sys/time.h> /* gettimeofday */
#include <pwd.h>
#include <sys/utsname.h> /* uname() */
#include <string.h>
+#include "para.h"
+#include "string.h"
free(argv);
return ret;
}
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;
+}
int read_size_header(const char *buf);
int create_argv(const char *buf, const char *delim, char ***result);
void free_argv(char **argv);
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);
*/
/** \file udp_recv.c Paraslash's udp receiver */
*/
/** \file udp_recv.c Paraslash's udp receiver */
#include <dirent.h>
#include <sys/socket.h>
#include <net/if.h>
#include <dirent.h>
#include <sys/socket.h>
#include <net/if.h>
/** \file udp_send.c Para_server's udp sender. */
/** \file udp_send.c Para_server's udp sender. */
#include <sys/time.h>
#include <dirent.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <dirent.h>
#include <sys/socket.h>
/** \file user_list.c User handling for para_server. */
/** \file user_list.c User handling for para_server. */
#include <sys/types.h>
#include <dirent.h>
#include <openssl/rc4.h>
#include <sys/types.h>
#include <dirent.h>
#include <openssl/rc4.h>
#include <dirent.h>
#include <osl.h>
#include <dirent.h>
#include <osl.h>
/** \file wav_filter.c A filter that inserts a wave header. */
/** \file wav_filter.c A filter that inserts a wave header. */
#include "para.h"
#include "error.h"
#include "para.h"
#include "error.h"
#include "list.h"
#include "sched.h"
#include "ggo.h"
#include "list.h"
#include "sched.h"
#include "ggo.h"
/** \file write.c Paraslash's standalone wav/raw player. */
/** \file write.c Paraslash's standalone wav/raw player. */
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
/** \file write_common.c common functions of para_audiod and para_write */
/** \file write_common.c common functions of para_audiod and para_write */
#include "para.h"
#include "string.h"
#include "list.h"
#include "para.h"
#include "string.h"
#include "list.h"