diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2011-10-04 18:23:45 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2011-10-04 18:23:45 +0000 |
commit | bfe39623ef6443a43c028fd595fbf4a08208d40a (patch) | |
tree | 45a46dc22bd444e773a07ca825b1513dc9ccd958 /navit | |
parent | fd10d2eb89487467ab46b99d1007257cd02a9f3c (diff) | |
download | navit-bfe39623ef6443a43c028fd595fbf4a08208d40a.tar.gz |
Add:Core:Integrated functions to add or remove an attribute
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4828 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r-- | navit/command.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/navit/command.c b/navit/command.c index c0c5aa194..be0463c73 100644 --- a/navit/command.c +++ b/navit/command.c @@ -153,6 +153,25 @@ command_object_get_attr(struct context *ctx, struct attr *object, enum attr_type return func->get_attr(object->u.data, attr_type, ret, NULL); } +static int +command_object_add_attr(struct context *ctx, struct attr *object, struct attr *attr) +{ + struct object_func *func=object_func_lookup(object->type); + if (!func || !func->add_attr) + return 0; + return func->add_attr(object->u.data, attr); +} + +static int +command_object_remove_attr(struct context *ctx, struct attr *object, struct attr *attr) +{ + struct object_func *func=object_func_lookup(object->type); + if (!func || !func->remove_attr) + return 0; + return func->remove_attr(object->u.data, attr); +} + + static void command_get_attr(struct context *ctx, struct result *res) { @@ -409,6 +428,10 @@ command_call_function(struct context *ctx, struct result *res) res->attr.u.data=func->create(NULL, list); } } + } else if (!strcmp(function,"add_attr")) { + command_object_add_attr(ctx, &res->attr, list[0]); + } else if (!strcmp(function,"remove_attr")) { + command_object_remove_attr(ctx, &res->attr, list[0]); } else { if (command_object_get_attr(ctx, &res->attr, attr_callback_list, &cbl)) { int valid; |