From: Russell Bryant rbryant@redhat.com
I noticed that the UUID lifetimes were case sensitive. This seemed overly restrictive so I changed it. I also added doxygen docs so that the valid lifetimes were documented for the API.
Signed-off-by: Russell Bryant rbryant@redhat.com --- src/include/matahari/host.h | 31 +++++++++++++++++++++++++++++-- src/lib/host.c | 12 ++++++------ 2 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/src/include/matahari/host.h b/src/include/matahari/host.h index f3bab48..ba540f7 100644 --- a/src/include/matahari/host.h +++ b/src/include/matahari/host.h @@ -29,9 +29,36 @@ #include <stdlib.h> #include <sigar.h>
+/** + * Get a UUID for a host. + * + * \param[in] lifetime This function can retrieve a few different UUIDs from + * different sources that each have different lifetimes. + * The valid lifetimes are: + * - "Hardware", unique to the host itself + * - "Filesystem", valid for the lifetime of the OS + * - "Reboot", reset on each reboot of the host + * - "Agent", reset on each execution of the agent serving up this information. + * - "Custom", set by mh_host_set_uuid() + * + * \return the UUID + */ +extern const char * +mh_host_get_uuid(const char *lifetime); + +/** + * Set a custom UUID for this host. + * + * \param[in] lifetime Which lifetime to set. The only valid input for + * this parameter right now is "Custom". + * \param[in] uuid the value of the UUID to set + * + * \retval 0 success + * \retval non-zero failure + */ +extern int +mh_host_set_uuid(const char *lifetime, const char *uuid);
-extern const char *mh_host_get_uuid(const char *lifetime); -extern int mh_host_set_uuid(const char *lifetime, const char *uuid); extern const char *mh_host_get_hostname(void); extern const char *mh_host_get_operating_system(void);
diff --git a/src/lib/host.c b/src/lib/host.c index a46f246..8a1416d 100644 --- a/src/lib/host.c +++ b/src/lib/host.c @@ -265,32 +265,32 @@ mh_host_get_uuid(const char *lifetime) static const char *agent_uuid = NULL; static const char *custom_uuid = NULL;
- if (lifetime == NULL || strcmp("Filesystem", lifetime) == 0) { + if (lifetime == NULL || strcasecmp("Filesystem", lifetime) == 0) { if (immutable_uuid == NULL) { immutable_uuid = mh_uuid(); } uuid = immutable_uuid;
- } else if (strcmp("Hardware", lifetime) == 0) { + } else if (strcasecmp("Hardware", lifetime) == 0) { if(hardware_uuid == NULL) { hardware_uuid = host_os_machine_uuid(); } uuid = hardware_uuid;
- } else if (strcmp("Reboot", lifetime) == 0) { + } else if (strcasecmp("Reboot", lifetime) == 0) {
if(reboot_uuid == NULL) { reboot_uuid = host_os_reboot_uuid(); } uuid = reboot_uuid;
- } else if (strcmp("Agent", lifetime) == 0) { + } else if (strcasecmp("Agent", lifetime) == 0) { if(agent_uuid == NULL) { agent_uuid = host_os_agent_uuid(); } uuid = agent_uuid;
- } else if (strcmp("Custom", lifetime) == 0) { + } else if (strcasecmp("Custom", lifetime) == 0) { if(custom_uuid == NULL) { custom_uuid = host_os_custom_uuid(); } @@ -310,7 +310,7 @@ mh_host_get_uuid(const char *lifetime) int mh_host_set_uuid(const char *lifetime, const char *uuid) { - if(lifetime && strcmp("Custom", lifetime) == 0) { + if(lifetime && strcasecmp("Custom", lifetime) == 0) { return host_os_set_custom_uuid(uuid); } return G_FILE_ERROR_NOSYS;
thanks
On Sat, Aug 13, 2011 at 6:26 AM, russell@russellbryant.net wrote:
From: Russell Bryant rbryant@redhat.com
I noticed that the UUID lifetimes were case sensitive. This seemed overly restrictive so I changed it. I also added doxygen docs so that the valid lifetimes were documented for the API.
Signed-off-by: Russell Bryant rbryant@redhat.com
src/include/matahari/host.h | 31 +++++++++++++++++++++++++++++-- src/lib/host.c | 12 ++++++------ 2 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/src/include/matahari/host.h b/src/include/matahari/host.h index f3bab48..ba540f7 100644 --- a/src/include/matahari/host.h +++ b/src/include/matahari/host.h @@ -29,9 +29,36 @@ #include <stdlib.h> #include <sigar.h>
+/**
- Get a UUID for a host.
- \param[in] lifetime This function can retrieve a few different UUIDs from
- different sources that each have different lifetimes.
- The valid lifetimes are:
- - "Hardware", unique to the host itself
- - "Filesystem", valid for the lifetime of the OS
- - "Reboot", reset on each reboot of the host
- - "Agent", reset on each execution of the agent serving up this information.
- - "Custom", set by mh_host_set_uuid()
- \return the UUID
- */
+extern const char * +mh_host_get_uuid(const char *lifetime);
+/**
- Set a custom UUID for this host.
- \param[in] lifetime Which lifetime to set. The only valid input for
- this parameter right now is "Custom".
- \param[in] uuid the value of the UUID to set
- \retval 0 success
- \retval non-zero failure
- */
+extern int +mh_host_set_uuid(const char *lifetime, const char *uuid);
-extern const char *mh_host_get_uuid(const char *lifetime); -extern int mh_host_set_uuid(const char *lifetime, const char *uuid); extern const char *mh_host_get_hostname(void); extern const char *mh_host_get_operating_system(void);
diff --git a/src/lib/host.c b/src/lib/host.c index a46f246..8a1416d 100644 --- a/src/lib/host.c +++ b/src/lib/host.c @@ -265,32 +265,32 @@ mh_host_get_uuid(const char *lifetime) static const char *agent_uuid = NULL; static const char *custom_uuid = NULL;
- if (lifetime == NULL || strcmp("Filesystem", lifetime) == 0) {
- if (lifetime == NULL || strcasecmp("Filesystem", lifetime) == 0) {
if (immutable_uuid == NULL) { immutable_uuid = mh_uuid(); } uuid = immutable_uuid;
- } else if (strcmp("Hardware", lifetime) == 0) {
- } else if (strcasecmp("Hardware", lifetime) == 0) {
if(hardware_uuid == NULL) { hardware_uuid = host_os_machine_uuid(); } uuid = hardware_uuid;
- } else if (strcmp("Reboot", lifetime) == 0) {
- } else if (strcasecmp("Reboot", lifetime) == 0) {
if(reboot_uuid == NULL) { reboot_uuid = host_os_reboot_uuid(); } uuid = reboot_uuid;
- } else if (strcmp("Agent", lifetime) == 0) {
- } else if (strcasecmp("Agent", lifetime) == 0) {
if(agent_uuid == NULL) { agent_uuid = host_os_agent_uuid(); } uuid = agent_uuid;
- } else if (strcmp("Custom", lifetime) == 0) {
- } else if (strcasecmp("Custom", lifetime) == 0) {
if(custom_uuid == NULL) { custom_uuid = host_os_custom_uuid(); } @@ -310,7 +310,7 @@ mh_host_get_uuid(const char *lifetime) int mh_host_set_uuid(const char *lifetime, const char *uuid) {
- if(lifetime && strcmp("Custom", lifetime) == 0) {
- if(lifetime && strcasecmp("Custom", lifetime) == 0) {
return host_os_set_custom_uuid(uuid); } return G_FILE_ERROR_NOSYS; -- 1.7.6
Matahari mailing list Matahari@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/matahari
matahari@lists.fedorahosted.org