add:core:Selecting the vehicle profile now works, but setting it on the vehicle doesn...
[navit-package] / navit / vehicleprofile.c
index f6875ae..9b2ae2a 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <glib.h>
 #include <string.h>
+#include <stdlib.h>
 #include "debug.h"
 #include "item.h"
 #include "roadprofile.h"
@@ -44,6 +45,14 @@ vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr)
        case attr_route_mode:
                this_->mode=attr->u.num;
                break;
+    case attr_name:
+        if(this_->name) free(this_->name);
+
+        // Only copy the first 1024 characters. Should be enough for
+        // normal use, but still prevent ludicrous memory allocations
+        // in case of a bug somewhere.
+        this_->name = strndup(attr->u.str, 2);
+        break;
        default:
                break;
        }
@@ -112,3 +121,9 @@ vehicleprofile_get_roadprofile(struct vehicleprofile *this_, enum item_type type
 {
        return g_hash_table_lookup(this_->roadprofile_hash, (void *)(long)type);
 }
+
+char *
+vehicleprofile_get_name(struct vehicleprofile *this_)
+{
+    return this_->name;
+}