* Factor regex stuff into fd.c, so that <regex.h> isn’t needed otherwhere.
This commit is contained in:
@@ -30,8 +30,9 @@
|
||||
#include "libzzuf.h"
|
||||
#include "fd.h"
|
||||
|
||||
regex_t * re_include = NULL;
|
||||
regex_t * re_exclude = NULL;
|
||||
/* Regex stuff */
|
||||
static regex_t * re_include = NULL;
|
||||
static regex_t * re_exclude = NULL;
|
||||
|
||||
/* File descriptor stuff */
|
||||
static struct files
|
||||
@@ -46,6 +47,28 @@ static struct files
|
||||
static int *fds;
|
||||
static int maxfd, nfiles;
|
||||
|
||||
void _zz_include(char const *regex)
|
||||
{
|
||||
re_include = malloc(sizeof(*re_include));
|
||||
|
||||
if(regcomp(re_include, regex, REG_EXTENDED) != 0)
|
||||
{
|
||||
free(re_include);
|
||||
re_include = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void _zz_exclude(char const *regex)
|
||||
{
|
||||
re_exclude = malloc(sizeof(*re_exclude));
|
||||
|
||||
if(regcomp(re_exclude, regex, REG_EXTENDED) != 0)
|
||||
{
|
||||
free(re_exclude);
|
||||
re_exclude = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void _zz_fd_init(void)
|
||||
{
|
||||
files = NULL;
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
* fd.h: file descriptor functions
|
||||
*/
|
||||
|
||||
extern void _zz_include(char const *);
|
||||
extern void _zz_exclude(char const *);
|
||||
extern void _zz_fd_init(void);
|
||||
extern void _zz_fd_fini(void);
|
||||
|
||||
extern regex_t * re_include;
|
||||
extern regex_t * re_exclude;
|
||||
|
||||
extern int _zz_mustwatch(char const *);
|
||||
extern int _zz_iswatched(int);
|
||||
extern void _zz_register(int);
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include "libzzuf.h"
|
||||
#include "debug.h"
|
||||
|
||||
+2
-9
@@ -29,7 +29,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <dlfcn.h>
|
||||
@@ -74,17 +73,11 @@ void _zz_init(void)
|
||||
|
||||
tmp = getenv("ZZUF_INCLUDE");
|
||||
if(tmp && *tmp)
|
||||
{
|
||||
re_include = malloc(sizeof(*re_include));
|
||||
regcomp(re_include, tmp, REG_EXTENDED);
|
||||
}
|
||||
_zz_include(tmp);
|
||||
|
||||
tmp = getenv("ZZUF_EXCLUDE");
|
||||
if(tmp && *tmp)
|
||||
{
|
||||
re_exclude = malloc(sizeof(*re_exclude));
|
||||
regcomp(re_exclude, tmp, REG_EXTENDED);
|
||||
}
|
||||
_zz_exclude(tmp);
|
||||
|
||||
tmp = getenv("ZZUF_SIGNAL");
|
||||
if(tmp && *tmp == '1')
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dlfcn.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
Reference in New Issue
Block a user