KR> # HG changeset patch
KR> # User Kaitlin Rupert <karupert(a)us.ibm.com>
KR> # Date 1195082890 28800
KR> # Node ID b4f0488c0d16a228a3c6fd6f23f7465cd3944123
KR> # Parent 6dc0a1a05c60ad08738c7c48aa9fb6d7dd7cd8be
KR> Add function to parse InstanceIDs.
Great!
KR> +bool parse_id(const CMPIObjectPath *ref,
KR> + char **name)
KR> +{
KR> + char *id = NULL;
KR> + char *pfx = NULL;
KR> + int ret;
KR> +
KR> + id = cu_get_str_path(ref, "InstanceID");
KR> + if (id == NULL)
KR> + return false;
KR> +
KR> + ret = sscanf(id, "%a[^:]:%as", &pfx, name);
KR> +
KR> + free(id);
KR> + free(pfx);
KR> +
KR> + if ((ret != 2) || (*name == NULL))
KR> + return false;
KR> +
KR> + return true;
KR> +}
What do you think about making parse_id() take a string id, and then
also exposing a wrapper function called parse_instanceid() that takes
the ref? I'd hate to bundle the actual parsing into a function that
takes such a complex type.
Also, since this is a library function and it could potentially be
used in other places down the road, I think it would be better to make
it return both sides of the id, as parse_fq_devid() does now. Yes, it
will require the caller to free() another string, but I think its
better that way.
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms(a)us.ibm.com