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
enhance documentation of ec_parse
[protos/libecoli.git]
/
src
/
ecoli_node_cmd.c
diff --git
a/src/ecoli_node_cmd.c
b/src/ecoli_node_cmd.c
index
b6b0720
..
5aac4e9
100644
(file)
--- a/
src/ecoli_node_cmd.c
+++ b/
src/ecoli_node_cmd.c
@@
-53,7
+53,7
@@
struct ec_node_cmd_ctx {
static int
ec_node_cmd_eval_var(void **result, void *userctx,
static int
ec_node_cmd_eval_var(void **result, void *userctx,
- const struct ec_p
ars
e *var)
+ const struct ec_p
nod
e *var)
{
const struct ec_strvec *vec;
struct ec_node_cmd_ctx *ctx = userctx;
{
const struct ec_strvec *vec;
struct ec_node_cmd_ctx *ctx = userctx;
@@
-62,7
+62,7
@@
ec_node_cmd_eval_var(void **result, void *userctx,
unsigned int i;
/* get parsed string vector, it should contain only one str */
unsigned int i;
/* get parsed string vector, it should contain only one str */
- vec = ec_p
arse
_strvec(var);
+ vec = ec_p
node_get
_strvec(var);
if (ec_strvec_len(vec) != 1) {
errno = EINVAL;
return -1;
if (ec_strvec_len(vec) != 1) {
errno = EINVAL;
return -1;
@@
-96,7
+96,7
@@
ec_node_cmd_eval_var(void **result, void *userctx,
static int
ec_node_cmd_eval_pre_op(void **result, void *userctx, void *operand,
static int
ec_node_cmd_eval_pre_op(void **result, void *userctx, void *operand,
- const struct ec_p
ars
e *operator)
+ const struct ec_p
nod
e *operator)
{
(void)result;
(void)userctx;
{
(void)result;
(void)userctx;
@@
-109,7
+109,7
@@
ec_node_cmd_eval_pre_op(void **result, void *userctx, void *operand,
static int
ec_node_cmd_eval_post_op(void **result, void *userctx, void *operand,
static int
ec_node_cmd_eval_post_op(void **result, void *userctx, void *operand,
- const struct ec_p
ars
e *operator)
+ const struct ec_p
nod
e *operator)
{
const struct ec_strvec *vec;
struct ec_node *in = operand;;
{
const struct ec_strvec *vec;
struct ec_node *in = operand;;
@@
-118,7
+118,7
@@
ec_node_cmd_eval_post_op(void **result, void *userctx, void *operand,
(void)userctx;
/* get parsed string vector, it should contain only one str */
(void)userctx;
/* get parsed string vector, it should contain only one str */
- vec = ec_p
arse
_strvec(operator);
+ vec = ec_p
node_get
_strvec(operator);
if (ec_strvec_len(vec) != 1) {
errno = EINVAL;
return -1;
if (ec_strvec_len(vec) != 1) {
errno = EINVAL;
return -1;
@@
-141,7
+141,7
@@
ec_node_cmd_eval_post_op(void **result, void *userctx, void *operand,
static int
ec_node_cmd_eval_bin_op(void **result, void *userctx, void *operand1,
static int
ec_node_cmd_eval_bin_op(void **result, void *userctx, void *operand1,
- const struct ec_p
ars
e *operator, void *operand2)
+ const struct ec_p
nod
e *operator, void *operand2)
{
const struct ec_strvec *vec;
{
const struct ec_strvec *vec;
@@
-152,7
+152,7
@@
ec_node_cmd_eval_bin_op(void **result, void *userctx, void *operand1,
(void)userctx;
/* get parsed string vector, it should contain only one str */
(void)userctx;
/* get parsed string vector, it should contain only one str */
- vec = ec_p
arse
_strvec(operator);
+ vec = ec_p
node_get
_strvec(operator);
if (ec_strvec_len(vec) > 1) {
errno = EINVAL;
return -1;
if (ec_strvec_len(vec) > 1) {
errno = EINVAL;
return -1;
@@
-223,8
+223,8
@@
ec_node_cmd_eval_bin_op(void **result, void *userctx, void *operand1,
static int
ec_node_cmd_eval_parenthesis(void **result, void *userctx,
static int
ec_node_cmd_eval_parenthesis(void **result, void *userctx,
- const struct ec_p
ars
e *open_paren,
- const struct ec_p
ars
e *close_paren,
+ const struct ec_p
nod
e *open_paren,
+ const struct ec_p
nod
e *close_paren,
void *value)
{
const struct ec_strvec *vec;
void *value)
{
const struct ec_strvec *vec;
@@
-235,7
+235,7
@@
ec_node_cmd_eval_parenthesis(void **result, void *userctx,
(void)close_paren;
/* get parsed string vector, it should contain only one str */
(void)close_paren;
/* get parsed string vector, it should contain only one str */
- vec = ec_p
arse
_strvec(open_paren);
+ vec = ec_p
node_get
_strvec(open_paren);
if (ec_strvec_len(vec) != 1) {
errno = EINVAL;
return -1;
if (ec_strvec_len(vec) != 1) {
errno = EINVAL;
return -1;
@@
-358,45
+358,41
@@
static struct ec_node *
ec_node_cmd_build(const char *cmd_str, struct ec_node **table, size_t len)
{
struct ec_node_cmd_ctx ctx = { table, len };
ec_node_cmd_build(const char *cmd_str, struct ec_node **table, size_t len)
{
struct ec_node_cmd_ctx ctx = { table, len };
- struct ec_p
ars
e *p = NULL;
+ struct ec_p
nod
e *p = NULL;
void *result;
int ret;
/* parse the command expression */
void *result;
int ret;
/* parse the command expression */
- p = ec_
node_
parse(ec_node_cmd_parser, cmd_str);
+ p = ec_parse(ec_node_cmd_parser, cmd_str);
if (p == NULL)
goto fail;
if (p == NULL)
goto fail;
- if (!ec_parse_matches(p)) {
- errno = EINVAL;
- goto fail;
- }
- if (!ec_parse_has_child(p)) {
+ if (!ec_pnode_matches(p)) {
errno = EINVAL;
goto fail;
}
ret = ec_node_expr_eval(&result, ec_node_cmd_expr,
errno = EINVAL;
goto fail;
}
ret = ec_node_expr_eval(&result, ec_node_cmd_expr,
- ec_p
ars
e_get_first_child(p),
+ ec_p
nod
e_get_first_child(p),
&expr_ops, &ctx);
if (ret < 0)
goto fail;
&expr_ops, &ctx);
if (ret < 0)
goto fail;
- ec_p
ars
e_free(p);
+ ec_p
nod
e_free(p);
return result;
fail:
return result;
fail:
- ec_p
ars
e_free(p);
+ ec_p
nod
e_free(p);
return NULL;
}
static int
return NULL;
}
static int
-ec_node_cmd_parse(const struct ec_node *node, struct ec_p
arse *
state,
+ec_node_cmd_parse(const struct ec_node *node, struct ec_p
node *p
state,
const struct ec_strvec *strvec)
{
struct ec_node_cmd *priv = ec_node_priv(node);
const struct ec_strvec *strvec)
{
struct ec_node_cmd *priv = ec_node_priv(node);
- return ec_
node_parse_child(priv->cmd,
state, strvec);
+ return ec_
parse_child(priv->cmd, p
state, strvec);
}
static int
}
static int
@@
-406,7
+402,7
@@
ec_node_cmd_complete(const struct ec_node *node,
{
struct ec_node_cmd *priv = ec_node_priv(node);
{
struct ec_node_cmd *priv = ec_node_priv(node);
- return ec_
node_
complete_child(priv->cmd, comp, strvec);
+ return ec_complete_child(priv->cmd, comp, strvec);
}
static void ec_node_cmd_free_priv(struct ec_node *node)
}
static void ec_node_cmd_free_priv(struct ec_node *node)
@@
-671,14
+667,14
@@
static int ec_node_cmd_testcase(void)
testres |= EC_TEST_CHECK_PARSE(node, 4, "good", "morning", "1", "bob");
testres |= EC_TEST_CHECK_COMPLETE(node,
testres |= EC_TEST_CHECK_PARSE(node, 4, "good", "morning", "1", "bob");
testres |= EC_TEST_CHECK_COMPLETE(node,
- "", EC_
NODE_ENDLIST
,
- "good", EC_
NODE_ENDLIST
);
+ "", EC_
VA_END
,
+ "good", EC_
VA_END
);
testres |= EC_TEST_CHECK_COMPLETE(node,
testres |= EC_TEST_CHECK_COMPLETE(node,
- "g", EC_
NODE_ENDLIST
,
- "good", EC_
NODE_ENDLIST
);
+ "g", EC_
VA_END
,
+ "good", EC_
VA_END
);
testres |= EC_TEST_CHECK_COMPLETE(node,
testres |= EC_TEST_CHECK_COMPLETE(node,
- "good", "morning", "", EC_
NODE_ENDLIST
,
- "bob", "bobby", "michael", EC_
NODE_ENDLIST
);
+ "good", "morning", "", EC_
VA_END
,
+ "bob", "bobby", "michael", EC_
VA_END
);
ec_node_free(node);
ec_node_free(node);