[patch 2/3] Move qemudParseUUID() to uuid.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Seems like the obvious place for it now ...

Signed-off-by: Mark McLoughlin <markmc@xxxxxxxxxx>

Index: libvirt/qemud/conf.c
===================================================================
--- libvirt.orig/qemud/conf.c
+++ libvirt/qemud/conf.c
@@ -47,54 +47,6 @@
 #include "iptables.h"
 #include "uuid.h"
 
-static int qemudParseUUID(const char *uuid,
-                          unsigned char *rawuuid) {
-    const char *cur;
-    int i;
-
-    /*
-     * do a liberal scan allowing '-' and ' ' anywhere between character
-     * pairs as long as there is 32 of them in the end.
-     */
-    cur = uuid;
-    for (i = 0;i < 16;) {
-        rawuuid[i] = 0;
-        if (*cur == 0)
-            goto error;
-        if ((*cur == '-') || (*cur == ' ')) {
-            cur++;
-            continue;
-        }
-        if ((*cur >= '0') && (*cur <= '9'))
-            rawuuid[i] = *cur - '0';
-        else if ((*cur >= 'a') && (*cur <= 'f'))
-            rawuuid[i] = *cur - 'a' + 10;
-        else if ((*cur >= 'A') && (*cur <= 'F'))
-            rawuuid[i] = *cur - 'A' + 10;
-        else
-            goto error;
-        rawuuid[i] *= 16;
-        cur++;
-        if (*cur == 0)
-            goto error;
-        if ((*cur >= '0') && (*cur <= '9'))
-            rawuuid[i] += *cur - '0';
-        else if ((*cur >= 'a') && (*cur <= 'f'))
-            rawuuid[i] += *cur - 'a' + 10;
-        else if ((*cur >= 'A') && (*cur <= 'F'))
-            rawuuid[i] += *cur - 'A' + 10;
-        else
-            goto error;
-        i++;
-        cur++;
-    }
-
-    return 0;
-
- error:
-    return -1;
-}
-
 /* Free all memory associated with a struct qemud_vm object */
 void qemudFreeVMDef(struct qemud_vm_def *def) {
     struct qemud_vm_disk_def *disk = def->disks;
Index: libvirt/qemud/uuid.c
===================================================================
--- libvirt.orig/qemud/uuid.c
+++ libvirt/qemud/uuid.c
@@ -89,6 +89,54 @@ qemudGenerateUUID(unsigned char *uuid)
     return qemudGeneratePseudoRandomBytes(uuid, QEMUD_UUID_RAW_LEN);
 }
 
+int
+qemudParseUUID(const char *uuid, unsigned char *rawuuid) {
+    const char *cur;
+    int i;
+
+    /*
+     * do a liberal scan allowing '-' and ' ' anywhere between character
+     * pairs as long as there is 32 of them in the end.
+     */
+    cur = uuid;
+    for (i = 0;i < 16;) {
+        rawuuid[i] = 0;
+        if (*cur == 0)
+            goto error;
+        if ((*cur == '-') || (*cur == ' ')) {
+            cur++;
+            continue;
+        }
+        if ((*cur >= '0') && (*cur <= '9'))
+            rawuuid[i] = *cur - '0';
+        else if ((*cur >= 'a') && (*cur <= 'f'))
+            rawuuid[i] = *cur - 'a' + 10;
+        else if ((*cur >= 'A') && (*cur <= 'F'))
+            rawuuid[i] = *cur - 'A' + 10;
+        else
+            goto error;
+        rawuuid[i] *= 16;
+        cur++;
+        if (*cur == 0)
+            goto error;
+        if ((*cur >= '0') && (*cur <= '9'))
+            rawuuid[i] += *cur - '0';
+        else if ((*cur >= 'a') && (*cur <= 'f'))
+            rawuuid[i] += *cur - 'a' + 10;
+        else if ((*cur >= 'A') && (*cur <= 'F'))
+            rawuuid[i] += *cur - 'A' + 10;
+        else
+            goto error;
+        i++;
+        cur++;
+    }
+
+    return 0;
+
+ error:
+    return -1;
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: nil
Index: libvirt/qemud/uuid.h
===================================================================
--- libvirt.orig/qemud/uuid.h
+++ libvirt/qemud/uuid.h
@@ -24,4 +24,7 @@
 
 int qemudGenerateUUID(unsigned char *uuid);
 
+int qemudParseUUID   (const char *uuid,
+		      unsigned char *rawuuid);
+
 #endif /* __QEMUD_UUID_H__ */

-- 


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]