summaryrefslogtreecommitdiff
path: root/navit/command.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-04-01 10:38:20 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-04-01 10:38:20 +0000
commit4d8d1a1bcdf14b5ab8c95deaa9e56652740ad845 (patch)
treeb3e58fc98e238d124abeefc648f4898251f26c56 /navit/command.c
parent568aaa0ec7c868c0c0b1e7a76a431a9e1631c792 (diff)
downloadnavit-4d8d1a1bcdf14b5ab8c95deaa9e56652740ad845.tar.gz
Add:Core:Improved command handling
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2177 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/command.c')
-rw-r--r--navit/command.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/navit/command.c b/navit/command.c
index 8594aa851..68e64d309 100644
--- a/navit/command.c
+++ b/navit/command.c
@@ -112,7 +112,7 @@ command_attr_type(struct result *res)
}
static int
-command_object_get_attr(struct attr *object, enum attr_type attr_type, struct attr *ret)
+command_object_get_attr(struct context *ctx, struct attr *object, enum attr_type attr_type, struct attr *ret)
{
struct object_func *func=object_func_lookup(object->type);
if (!func || !func->get_attr)
@@ -125,7 +125,7 @@ command_get_attr(struct context *ctx, struct result *res)
{
int result;
enum attr_type attr_type=command_attr_type(res);
- result=command_object_get_attr(&res->attr, attr_type, &res->attr);
+ result=command_object_get_attr(ctx, &res->attr, attr_type, &res->attr);
if (result) {
res->var=res->attrn;
res->varlen=res->attrnlen;
@@ -314,7 +314,7 @@ command_call_function(struct context *ctx, struct result *res)
ctx->error=missing_closing_brace;
return;
}
- if (command_object_get_attr(&res->attr, attr_callback_list, &cbl)) {
+ if (command_object_get_attr(ctx, &res->attr, attr_callback_list, &cbl)) {
int valid;
dbg(0,"function call %s from %s\n",function, attr_to_name(res->attr.type));
callback_list_call_attr_4(cbl.u.callback_list, attr_command, function, list, NULL, &valid);
@@ -663,16 +663,34 @@ command_evaluate_to_string(struct attr *attr, char *expr, int **error)
char *ret;
command_evaluate_to(attr, expr, &ctx, &res);
- if (error)
- *error=ctx.error;
if (!ctx.error)
ret=get_string(&ctx, &res);
+ if (error)
+ *error=ctx.error;
if (ctx.error)
return NULL;
else
return ret;
}
+int
+command_evaluate_to_int(struct attr *attr, char *expr, int **error)
+{
+ struct result res;
+ struct context ctx;
+ char *ret;
+
+ command_evaluate_to(attr, expr, &ctx, &res);
+ if (!ctx.error)
+ ret=get_int(&ctx, &res);
+ if (error)
+ *error=ctx.error;
+ if (ctx.error)
+ return 0;
+ else
+ return ret;
+}
+
void
command_evaluate(struct attr *attr, char *expr)
{