ia64/xen-unstable

changeset 14758:a00c629f67be

Serialize string string maps.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author Ewan Mellor <ewan@xensource.com>
date Thu Apr 05 18:47:04 2007 +0100 (2007-04-05)
parents 67f4f21f76e9
children 5a7eebbae5dc
files tools/libxen/src/xen_common.c
line diff
     1.1 --- a/tools/libxen/src/xen_common.c	Thu Apr 05 18:12:35 2007 +0100
     1.2 +++ b/tools/libxen/src/xen_common.c	Thu Apr 05 18:47:04 2007 +0100
     1.3 @@ -102,6 +102,9 @@ add_struct_value(const struct abstract_t
     1.4                            const char *),
     1.5                   const char *, xmlNode *);
     1.6  
     1.7 +static xmlNode *
     1.8 +add_container(xmlNode *parent, const char *name);
     1.9 +
    1.10  static void
    1.11  call_raw(xen_session *, const char *, abstract_value [], int,
    1.12           const abstract_type *, void *);
    1.13 @@ -1290,6 +1293,48 @@ make_body_add_type(enum abstract_typenam
    1.14      }
    1.15      break;
    1.16  
    1.17 +    case MAP:
    1.18 +    {
    1.19 +        const struct struct_member *member = v->type->members;
    1.20 +        arbitrary_map *map_val = v->u.struct_val;
    1.21 +        xmlNode *param_node = add_param_struct(params_node);
    1.22 +        for (size_t i = 0; i < map_val->size; i++) {
    1.23 +            enum abstract_typename typename_key = member[0].type->typename;
    1.24 +            enum abstract_typename typename_val = member[1].type->typename;
    1.25 +            int offset_key = member[0].offset;
    1.26 +            int offset_val = member[1].offset;
    1.27 +            int struct_size = v->type->struct_size;
    1.28 +
    1.29 +            switch (typename_key) {
    1.30 +            case STRING: {
    1.31 +                char **addr = (void *)(map_val + 1) +
    1.32 +                             (i * struct_size) +
    1.33 +                             offset_key;
    1.34 +                char *key = *addr;
    1.35 +
    1.36 +                switch (typename_val) {
    1.37 +                case STRING: {
    1.38 +                    char *val;
    1.39 +                    addr = (void *)(map_val + 1) +
    1.40 +                           (i * struct_size) +
    1.41 +                           offset_val;
    1.42 +                    val = *addr;
    1.43 +                    add_struct_member(param_node, key, "string", val);
    1.44 +                    break;
    1.45 +                }
    1.46 +                default:
    1.47 +                    assert(false);
    1.48 +                }
    1.49 +                break;
    1.50 +            }
    1.51 +            default:
    1.52 +                assert(false);
    1.53 +            }
    1.54 +        }
    1.55 +    }
    1.56 +    break;
    1.57 +
    1.58 +
    1.59      default:
    1.60          assert(false);
    1.61      }