]> xenbits.xensource.com Git - libvirt.git/commitdiff
Move hextobin as virHexToBin to util.c
authorMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 27 Aug 2010 21:13:45 +0000 (23:13 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Mon, 30 Aug 2010 20:21:54 +0000 (22:21 +0200)
virHexToBin will be used in the .vmx handling code.

src/util/util.c
src/util/util.h
src/util/uuid.c

index 9679dc908f1f8cd815b3c88cf9c2c499cf0cea11..b6b971206618227a161870db25bfc184823fb284 100644 (file)
@@ -2089,6 +2089,21 @@ virStrToDouble(char const *s,
     return 0;
 }
 
+/* Convert C from hexadecimal character to integer.  */
+int
+virHexToBin(unsigned char c)
+{
+    switch (c) {
+    default: return c - '0';
+    case 'a': case 'A': return 10;
+    case 'b': case 'B': return 11;
+    case 'c': case 'C': return 12;
+    case 'd': case 'D': return 13;
+    case 'e': case 'E': return 14;
+    case 'f': case 'F': return 15;
+    }
+}
+
 /**
  * virSkipSpaces:
  * @str: pointer to the char pointer used
index 476eac43b793cdd93362f83101c5ea6741e87184..5de4fd67d4825da3b5ac0820ae721dd6d9a92333 100644 (file)
@@ -194,6 +194,8 @@ int virStrToDouble(char const *s,
                    char **end_ptr,
                    double *result);
 
+int virHexToBin(unsigned char c);
+
 int virMacAddrCompare (const char *mac1, const char *mac2);
 
 void virSkipSpaces(const char **str);
index 9cafc2ada14b582f486f1832e5c9a570e4e0c688..969ac6d275a7706a910c5c61222a93c9209c63d7 100644 (file)
@@ -113,22 +113,6 @@ virUUIDGenerate(unsigned char *uuid)
     return(err);
 }
 
-/* Convert C from hexadecimal character to integer.  */
-static int
-hextobin (unsigned char c)
-{
-  switch (c)
-    {
-    default: return c - '0';
-    case 'a': case 'A': return 10;
-    case 'b': case 'B': return 11;
-    case 'c': case 'C': return 12;
-    case 'd': case 'D': return 13;
-    case 'e': case 'E': return 14;
-    case 'f': case 'F': return 15;
-    }
-}
-
 /**
  * virUUIDParse:
  * @uuidstr: zero terminated string representation of the UUID
@@ -166,14 +150,14 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid) {
         }
         if (!c_isxdigit(*cur))
             goto error;
-        uuid[i] = hextobin(*cur);
+        uuid[i] = virHexToBin(*cur);
         uuid[i] *= 16;
         cur++;
         if (*cur == 0)
             goto error;
         if (!c_isxdigit(*cur))
             goto error;
-        uuid[i] += hextobin(*cur);
+        uuid[i] += virHexToBin(*cur);
         i++;
         cur++;
     }