2023-02-27 02:34:43 +00:00
|
|
|
#include <regex.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "jsoncdaccord.h"
|
2023-02-27 06:10:36 +00:00
|
|
|
#include "../../include/zlog_module.h"
|
2023-02-27 02:34:43 +00:00
|
|
|
|
|
|
|
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) {
|
2023-02-27 06:10:36 +00:00
|
|
|
LOG_MOD(error, ZLOG_MOD_JSCHEM, "Could not compile regex\n");
|
2023-02-27 02:34:43 +00:00
|
|
|
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;
|
|
|
|
}
|