]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Moved some SEXPR functions from xen-unified
authorMarkus Groß <gross@univention.de>
Mon, 21 Feb 2011 13:40:07 +0000 (14:40 +0100)
committerEric Blake <eblake@redhat.com>
Mon, 21 Feb 2011 17:50:18 +0000 (10:50 -0700)
src/util/sexpr.c
src/util/sexpr.h
src/xen/xend_internal.c

index 330280e1cacbeceff0cb21c5a878108dc71bfcf1..7f142060b105b5119c82526fdd371e7f703f4597 100644 (file)
@@ -566,3 +566,67 @@ sexpr_fmt_node(const struct sexpr *sexpr, const char *fmt, ...)
 
     return sexpr_node(sexpr, node);
 }
+
+/**
+ * sexpr_int:
+ * @sexpr: an S-Expression
+ * @name: the name for the value
+ *
+ * convenience function to lookup an int value in the S-Expression
+ *
+ * Returns the value found or 0 if not found (but may not be an error).
+ * This function suffers from the flaw that zero is both a correct
+ * return value and an error indicator: careful!
+ */
+int
+sexpr_int(const struct sexpr *sexpr, const char *name)
+{
+    const char *value = sexpr_node(sexpr, name);
+
+    if (value) {
+        return strtol(value, NULL, 0);
+    }
+    return 0;
+}
+
+
+/**
+ * sexpr_float:
+ * @sexpr: an S-Expression
+ * @name: the name for the value
+ *
+ * convenience function to lookup a float value in the S-Expression
+ *
+ * Returns the value found or 0 if not found (but may not be an error)
+ */
+double
+sexpr_float(const struct sexpr *sexpr, const char *name)
+{
+    const char *value = sexpr_node(sexpr, name);
+
+    if (value) {
+        return strtod(value, NULL);
+    }
+    return 0;
+}
+
+/**
+ * sexpr_u64:
+ * @sexpr: an S-Expression
+ * @name: the name for the value
+ *
+ * convenience function to lookup a 64bits unsigned int value in the
+ * S-Expression
+ *
+ * Returns the value found or 0 if not found (but may not be an error)
+ */
+uint64_t
+sexpr_u64(const struct sexpr *sexpr, const char *name)
+{
+    const char *value = sexpr_node(sexpr, name);
+
+    if (value) {
+        return strtoll(value, NULL, 0);
+    }
+    return 0;
+}
index 04125eae65e745c8e2b3f4a55f065dea51d34d6c..dc6687d6dcc56e1a26644a8a3cf72e3967e5ce3f 100644 (file)
@@ -16,6 +16,7 @@
 # include "internal.h"
 
 # include <sys/types.h>
+# include <stdint.h>
 
 enum sexpr_type {
     SEXPR_NIL,
@@ -52,4 +53,9 @@ const char *sexpr_fmt_node(const struct sexpr *sexpr, const char *fmt, ...)
   ATTRIBUTE_FMT_PRINTF(2,3);
 struct sexpr *sexpr_lookup(const struct sexpr *sexpr, const char *node);
 int sexpr_has(const struct sexpr *sexpr, const char *node);
+
+int sexpr_int(const struct sexpr *sexpr, const char *name);
+double sexpr_float(const struct sexpr *sexpr, const char *name);
+uint64_t sexpr_u64(const struct sexpr *sexpr, const char *name);
+
 #endif
index da8269d59139b2b329c771952fbda95e5bfc4f65..346fb8f9a7537b29bb68f3ba5e3f56fe65182788 100644 (file)
@@ -601,71 +601,6 @@ cleanup:
     return res;
 }
 
-/**
- * sexpr_int:
- * @sexpr: an S-Expression
- * @name: the name for the value
- *
- * convenience function to lookup an int value in the S-Expression
- *
- * Returns the value found or 0 if not found (but may not be an error).
- * This function suffers from the flaw that zero is both a correct
- * return value and an error indicator: careful!
- */
-static int
-sexpr_int(const struct sexpr *sexpr, const char *name)
-{
-    const char *value = sexpr_node(sexpr, name);
-
-    if (value) {
-        return strtol(value, NULL, 0);
-    }
-    return 0;
-}
-
-
-/**
- * sexpr_float:
- * @sexpr: an S-Expression
- * @name: the name for the value
- *
- * convenience function to lookup a float value in the S-Expression
- *
- * Returns the value found or 0 if not found (but may not be an error)
- */
-static double
-sexpr_float(const struct sexpr *sexpr, const char *name)
-{
-    const char *value = sexpr_node(sexpr, name);
-
-    if (value) {
-        return strtod(value, NULL);
-    }
-    return 0;
-}
-
-/**
- * sexpr_u64:
- * @sexpr: an S-Expression
- * @name: the name for the value
- *
- * convenience function to lookup a 64bits unsigned int value in the
- * S-Expression
- *
- * Returns the value found or 0 if not found (but may not be an error)
- */
-static uint64_t
-sexpr_u64(const struct sexpr *sexpr, const char *name)
-{
-    const char *value = sexpr_node(sexpr, name);
-
-    if (value) {
-        return strtoll(value, NULL, 0);
-    }
-    return 0;
-}
-
-
 /**
  * sexpr_uuid:
  * @ptr: where to store the UUID, incremented