git.droids-corp.org
/
protos
/
libecoli.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
api documentation for ec_parse
[protos/libecoli.git]
/
src
/
ecoli_node_re.c
diff --git
a/src/ecoli_node_re.c
b/src/ecoli_node_re.c
index
69f352c
..
4bbc192
100644
(file)
--- a/
src/ecoli_node_re.c
+++ b/
src/ecoli_node_re.c
@@
-21,27
+21,26
@@
EC_LOG_TYPE_REGISTER(node_re);
struct ec_node_re {
EC_LOG_TYPE_REGISTER(node_re);
struct ec_node_re {
- struct ec_node gen;
char *re_str;
regex_t re;
};
static int
char *re_str;
regex_t re;
};
static int
-ec_node_re_parse(const struct ec_node *
gen_
node,
- struct ec_p
arse *
state,
+ec_node_re_parse(const struct ec_node *node,
+ struct ec_p
node *p
state,
const struct ec_strvec *strvec)
{
const struct ec_strvec *strvec)
{
- struct ec_node_re *
node = (struct ec_node_re *)gen_node
;
+ struct ec_node_re *
priv = ec_node_priv(node)
;
const char *str;
regmatch_t pos;
const char *str;
regmatch_t pos;
- (void)state;
+ (void)
p
state;
if (ec_strvec_len(strvec) == 0)
return EC_PARSE_NOMATCH;
str = ec_strvec_val(strvec, 0);
if (ec_strvec_len(strvec) == 0)
return EC_PARSE_NOMATCH;
str = ec_strvec_val(strvec, 0);
- if (regexec(&
node
->re, str, 1, &pos, 0) != 0)
+ if (regexec(&
priv
->re, str, 1, &pos, 0) != 0)
return EC_PARSE_NOMATCH;
if (pos.rm_so != 0 || pos.rm_eo != (int)strlen(str))
return EC_PARSE_NOMATCH;
return EC_PARSE_NOMATCH;
if (pos.rm_so != 0 || pos.rm_eo != (int)strlen(str))
return EC_PARSE_NOMATCH;
@@
-49,13
+48,13
@@
ec_node_re_parse(const struct ec_node *gen_node,
return 1;
}
return 1;
}
-static void ec_node_re_free_priv(struct ec_node *
gen_
node)
+static void ec_node_re_free_priv(struct ec_node *node)
{
{
- struct ec_node_re *
node = (struct ec_node_re *)gen_node
;
+ struct ec_node_re *
priv = ec_node_priv(node)
;
- if (
node
->re_str != NULL) {
- ec_free(
node
->re_str);
- regfree(&
node
->re);
+ if (
priv
->re_str != NULL) {
+ ec_free(
priv
->re_str);
+ regfree(&
priv
->re);
}
}
}
}
@@
-70,10
+69,10
@@
static const struct ec_config_schema ec_node_re_schema[] = {
},
};
},
};
-static int ec_node_re_set_config(struct ec_node *
gen_
node,
+static int ec_node_re_set_config(struct ec_node *node,
const struct ec_config *config)
{
const struct ec_config *config)
{
- struct ec_node_re *
node = (struct ec_node_re *)gen_node
;
+ struct ec_node_re *
priv = ec_node_priv(node)
;
const struct ec_config *value = NULL;
char *s = NULL;
regex_t re;
const struct ec_config *value = NULL;
char *s = NULL;
regex_t re;
@@
-98,12
+97,12
@@
static int ec_node_re_set_config(struct ec_node *gen_node,
goto fail;
}
goto fail;
}
- if (
node
->re_str != NULL) {
- ec_free(
node
->re_str);
- regfree(&
node
->re);
+ if (
priv
->re_str != NULL) {
+ ec_free(
priv
->re_str);
+ regfree(&
priv
->re);
}
}
-
node
->re_str = s;
-
node
->re = re;
+
priv
->re_str = s;
+
priv
->re = re;
return 0;
return 0;
@@
-117,21
+116,20
@@
static struct ec_node_type ec_node_re_type = {
.schema = ec_node_re_schema,
.set_config = ec_node_re_set_config,
.parse = ec_node_re_parse,
.schema = ec_node_re_schema,
.set_config = ec_node_re_set_config,
.parse = ec_node_re_parse,
- .complete = ec_node_complete_unknown,
.size = sizeof(struct ec_node_re),
.free_priv = ec_node_re_free_priv,
};
EC_NODE_TYPE_REGISTER(ec_node_re_type);
.size = sizeof(struct ec_node_re),
.free_priv = ec_node_re_free_priv,
};
EC_NODE_TYPE_REGISTER(ec_node_re_type);
-int ec_node_re_set_regexp(struct ec_node *
gen_
node, const char *str)
+int ec_node_re_set_regexp(struct ec_node *node, const char *str)
{
struct ec_config *config = NULL;
int ret;
EC_CHECK_ARG(str != NULL, -1, EINVAL);
{
struct ec_config *config = NULL;
int ret;
EC_CHECK_ARG(str != NULL, -1, EINVAL);
- if (ec_node_check_type(
gen_
node, &ec_node_re_type) < 0)
+ if (ec_node_check_type(node, &ec_node_re_type) < 0)
goto fail;
config = ec_config_dict();
goto fail;
config = ec_config_dict();
@@
-142,7
+140,7
@@
int ec_node_re_set_regexp(struct ec_node *gen_node, const char *str)
if (ret < 0)
goto fail;
if (ret < 0)
goto fail;
- ret = ec_node_set_config(
gen_
node, config);
+ ret = ec_node_set_config(node, config);
config = NULL;
if (ret < 0)
goto fail;
config = NULL;
if (ret < 0)
goto fail;
@@
-156,19
+154,19
@@
fail:
struct ec_node *ec_node_re(const char *id, const char *re_str)
{
struct ec_node *ec_node_re(const char *id, const char *re_str)
{
- struct ec_node *
gen_
node = NULL;
+ struct ec_node *node = NULL;
-
gen_
node = ec_node_from_type(&ec_node_re_type, id);
- if (
gen_
node == NULL)
+ node = ec_node_from_type(&ec_node_re_type, id);
+ if (node == NULL)
goto fail;
goto fail;
- if (ec_node_re_set_regexp(
gen_
node, re_str) < 0)
+ if (ec_node_re_set_regexp(node, re_str) < 0)
goto fail;
goto fail;
- return
gen_
node;
+ return node;
fail:
fail:
- ec_node_free(
gen_
node);
+ ec_node_free(node);
return NULL;
}
return NULL;
}