diff options
Diffstat (limited to 'utils/misc.c')
-rw-r--r-- | utils/misc.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/utils/misc.c b/utils/misc.c new file mode 100644 index 0000000..d88f743 --- /dev/null +++ b/utils/misc.c @@ -0,0 +1,21 @@ +#include <regex.h> +#include <netdb.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int +re_match(const char *string, char *pattern) +{ + int status; + regex_t re; + if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0) { + return 0; + } + status = regexec(&re, string, (size_t) 0, NULL, 0); + regfree(&re); + if (status != 0) { + return 0; + } + return 1; +} |