mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
Mon Feb 26 15:33:08 IST 2007 Mark McLoughlin <markmc@redhat.com>
* qemud/conf.c, qemud/uuid.[ch]: move qemudParseUUID() into uuid.c
This commit is contained in:
parent
bce1d26ef3
commit
35f911c815
@ -1,3 +1,8 @@
|
||||
Mon Feb 26 15:33:08 IST 2007 Mark McLoughlin <markmc@redhat.com>
|
||||
|
||||
* qemud/conf.c, qemud/uuid.[ch]: move qemudParseUUID()
|
||||
into uuid.c
|
||||
|
||||
Mon Feb 26 15:31:23 IST 2007 Mark McLoughlin <markmc@redhat.com>
|
||||
|
||||
* qemud/uuid.[ch]: add uuid generation code
|
||||
|
48
qemud/conf.c
48
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;
|
||||
|
48
qemud/uuid.c
48
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
|
||||
|
@ -24,4 +24,7 @@
|
||||
|
||||
int qemudGenerateUUID(unsigned char *uuid);
|
||||
|
||||
int qemudParseUUID (const char *uuid,
|
||||
unsigned char *rawuuid);
|
||||
|
||||
#endif /* __QEMUD_UUID_H__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user