WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Implement parsing of datetimes.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Implement parsing of datetimes.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 23 Mar 2007 11:10:15 -0700
Delivery-date: Fri, 23 Mar 2007 11:09:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1174656368 0
# Node ID 931c4b77ea7dc244145250b128f8010cd6e22b18
# Parent  fbe72d878196c59b5085f1e2166b3b70cf6ef4dc
Implement parsing of datetimes.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/libxen/src/xen_common.c |   43 ++++++++++++++++++++++++++++++++----------
 1 files changed, 33 insertions(+), 10 deletions(-)

diff -r fbe72d878196 -r 931c4b77ea7d tools/libxen/src/xen_common.c
--- a/tools/libxen/src/xen_common.c     Fri Mar 23 11:52:09 2007 +0000
+++ b/tools/libxen/src/xen_common.c     Fri Mar 23 13:26:08 2007 +0000
@@ -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, xml
 
 
 /**
- * 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,
@@ -620,6 +624,25 @@ static void parse_into(xen_session *s, x
         else
         {
             ((bool *)value)[slot] = (0 == strcmp((char *)string, "1"));
+            free(string);
+        }
+    }
+    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);
         }
     }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Implement parsing of datetimes., Xen patchbot-unstable <=