ia64/xen-unstable
changeset 12177:5cccc3ed0b1e
Fix marshalling to and from record_opts.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Signed-off-by: Ewan Mellor <ewan@xensource.com>
author | Ewan Mellor <ewan@xensource.com> |
---|---|
date | Sat Oct 28 12:00:02 2006 +0100 (2006-10-28) |
parents | de00775e39da |
children | 4ea1097252a1 |
files | tools/libxen/src/xen_common.c |
line diff
1.1 --- a/tools/libxen/src/xen_common.c Sat Oct 28 11:54:05 2006 +0100 1.2 +++ b/tools/libxen/src/xen_common.c Sat Oct 28 12:00:02 2006 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - Copyright (c) 2006 XenSource, Inc. 1.6 + * Copyright (c) 2006 XenSource, Inc. 1.7 * 1.8 * This library is free software; you can redistribute it and/or 1.9 * modify it under the terms of the GNU Lesser General Public 1.10 @@ -14,7 +14,7 @@ 1.11 * You should have received a copy of the GNU Lesser General Public 1.12 * License along with this library; if not, write to the Free Software 1.13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1.14 -*/ 1.15 + */ 1.16 1.17 #include <assert.h> 1.18 #include <stdarg.h> 1.19 @@ -48,11 +48,17 @@ typedef struct 1.20 1.21 typedef struct 1.22 { 1.23 + void *handle; 1.24 +} arbitrary_record; 1.25 + 1.26 + 1.27 +typedef struct 1.28 +{ 1.29 bool is_record; 1.30 union 1.31 { 1.32 char *handle; 1.33 - void *record; 1.34 + arbitrary_record *record; 1.35 } u; 1.36 } arbitrary_record_opt; 1.37 1.38 @@ -449,6 +455,18 @@ static void destring(xen_session *s, xml 1.39 } 1.40 1.41 1.42 +/** 1.43 + * result_type : STRING => value : char **, the char * is yours. 1.44 + * result_type : ENUM => value : int * 1.45 + * result_type : INT => value : uint64_t * 1.46 + * result_type : FLOAT => value : double * 1.47 + * result_type : BOOL => value : bool * 1.48 + * result_type : SET => value : arbitrary_set **, the set is yours. 1.49 + * result_type : MAP => value : arbitrary_map **, the map is yours. 1.50 + * result_type : OPT => value : arbitrary_record_opt **, 1.51 + * the record is yours, the handle is filled. 1.52 + * result_type : STRUCT => value : void **, the void * is yours. 1.53 + */ 1.54 static void parse_into(xen_session *s, xmlNode *value_node, 1.55 const abstract_type *result_type, void *value, 1.56 int slot) 1.57 @@ -809,7 +827,7 @@ static size_t size_of_member(const abstr 1.58 return sizeof(int); 1.59 1.60 case REF: 1.61 - return sizeof(arbitrary_record_opt); 1.62 + return sizeof(arbitrary_record_opt *); 1.63 1.64 default: 1.65 assert(false); 1.66 @@ -1100,6 +1118,22 @@ add_struct_value(const struct abstract_t 1.67 switch (type->typename) 1.68 { 1.69 case REF: 1.70 + { 1.71 + arbitrary_record_opt *val = *(arbitrary_record_opt **)value; 1.72 + if (val != NULL) 1.73 + { 1.74 + if (val->is_record) 1.75 + { 1.76 + adder(node, key, "string", val->u.record->handle); 1.77 + } 1.78 + else 1.79 + { 1.80 + adder(node, key, "string", val->u.handle); 1.81 + } 1.82 + } 1.83 + } 1.84 + break; 1.85 + 1.86 case STRING: 1.87 { 1.88 char *val = *(char **)value;