提交 1fe2927a 编写于 作者: M Matthias Bolte

Move hextobin as virHexToBin to util.c

virHexToBin will be used in the .vmx handling code.
上级 09d37bde
......@@ -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
......
......@@ -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);
......
......@@ -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++;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册