diff options
author | Ewan Mellor <ewan@xensource.com> | 2007-03-23 13:26:08 +0000 |
---|---|---|
committer | Ewan Mellor <ewan@xensource.com> | 2007-03-23 13:26:08 +0000 |
commit | 6dcfe86140cefa9d91a55a9412f44b87fadb3b39 (patch) | |
tree | 6d5f27ee2fe667fbe80bf6de0fabae77dd3d8574 /tools/libxen | |
parent | 07b55ea54a3d258c59e4f15ba10dfc70ccec244e (diff) | |
download | xen-6dcfe86140cefa9d91a55a9412f44b87fadb3b39.tar.gz xen-6dcfe86140cefa9d91a55a9412f44b87fadb3b39.tar.bz2 xen-6dcfe86140cefa9d91a55a9412f44b87fadb3b39.zip |
Implement parsing of datetimes.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/libxen')
-rw-r--r-- | tools/libxen/src/xen_common.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/tools/libxen/src/xen_common.c b/tools/libxen/src/xen_common.c index f2c9644521..a22456c85e 100644 --- a/tools/libxen/src/xen_common.c +++ b/tools/libxen/src/xen_common.c @@ -16,12 +16,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define _XOPEN_SOURCE #include <assert.h> #include <stdarg.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <libxml/parser.h> #include <libxml/tree.h> @@ -493,16 +495,18 @@ static void destring(xen_session *s, xmlChar *name, const abstract_type *type, /** - * result_type : STRING => value : char **, the char * is yours. - * result_type : ENUM => value : int * - * result_type : INT => value : int64_t * - * result_type : FLOAT => value : double * - * result_type : BOOL => value : bool * - * result_type : SET => value : arbitrary_set **, the set is yours. - * result_type : MAP => value : arbitrary_map **, the map is yours. - * result_type : OPT => value : arbitrary_record_opt **, - * the record is yours, the handle is filled. - * result_type : STRUCT => value : void **, the void * is yours. + * result_type : STRING => value : char **, the char * is yours. + * result_type : ENUM => value : int * + * result_type : INT => value : int64_t * + * result_type : FLOAT => value : double * + * result_type : BOOL => value : bool * + * result_type : DATETIME => value : time_t * + * result_type : SET => value : arbitrary_set **, the set is yours. + * result_type : MAP => value : arbitrary_map **, the map is yours. + * result_type : OPT => value : arbitrary_record_opt **, + * the record is yours, the handle is + * filled. + * result_type : STRUCT => value : void **, the void * is yours. */ static void parse_into(xen_session *s, xmlNode *value_node, const abstract_type *result_type, void *value, @@ -625,6 +629,25 @@ static void parse_into(xen_session *s, xmlNode *value_node, } break; + case DATETIME: + { + xmlChar *string = string_from_value(value_node, "dateTime.iso8601"); + if (string == NULL) + { + server_error( + s, "Expected an DateTime from the server but didn't get one"); + } + else + { + struct tm tm; + memset(&tm, 0, sizeof(tm)); + strptime((char *)string, "%Y%m%dT%H:%M:%S", &tm); + ((time_t *)value)[slot] = (time_t)mktime(&tm); + free(string); + } + } + break; + case SET: { if (!is_container_node(value_node, "value") || |