21 lines
586 B
C
21 lines
586 B
C
#include <regex.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "jsoncdaccord.h"
|
|
#include "../../include/zlog_module.h"
|
|
|
|
int _jdac_match_string_with_regex(const char *regex_pattern, const char *value) {
|
|
regex_t regex;
|
|
int reti = regcomp(®ex, regex_pattern, REG_EXTENDED);
|
|
if (reti) {
|
|
LOG_MOD(error, ZLOG_MOD_JSCHEM, "Could not compile regex\n");
|
|
return JDAC_REGEX_COMPILE_FAILED;
|
|
}
|
|
reti = regexec(®ex, value, 0, NULL, 0);
|
|
regfree(®ex);
|
|
if (reti == 0) {
|
|
return JDAC_REGEX_MATCH;
|
|
}
|
|
return JDAC_REGEX_MISMATCH;
|
|
}
|