This is an object to handle some of the names used in X.509. We need this object approach because those names may come as a set and there is no other clean way to access them.
This function releases the object name. Passing
NULL
is allowed.
By iterating idx up starting with 0, this function returns all General Names stored in name. The format of the returned name is either a RFC-2253 formated one which can be detected by checking whether the first character is letter or a digit. RFC 2822 conformant email addresses are returned enclosed in angle brackets, the opening angle bracket should be used to detect this. Other formats are returned as an S-Expression in canonical format, so an opening parenthesis may be used to detect this encoding, in this case the name may include binary null characters, so strlen might return a length shorter than actually used, the real length is implicitly given by the structure of the S-Exp, an extra null is appended for safety reasons. One common format return is a Universal Resource Identifier which has the S-expression: `(uri <urivalue>)'.
The returned string has the same lifetime as name.
Convenience function to return names representing an URI. Caller must free the returned value. Note that this function should not be used to enumerate the names.
Here is an example on how you can use this function to enumerate all URIs:
void print_names (ksba_name_t name) { int idx; const char *s; for (idx=0; (s = ksba_name_enum (name, idx)); idx++) { char *p = ksba_name_get_uri (name, idx); if (p) { puts (p); ksba_free (p); } } }