mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
util: add helper API for getting URI parameters
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
dee2218bc8
commit
fd2a9dda87
@ -3334,6 +3334,7 @@ virTypedParamsValidate;
|
||||
virURIFormat;
|
||||
virURIFormatParams;
|
||||
virURIFree;
|
||||
virURIGetParam;
|
||||
virURIParse;
|
||||
virURIResolveAlias;
|
||||
|
||||
|
@ -376,3 +376,19 @@ virURIResolveAlias(virConfPtr conf, const char *alias, char **uri)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
virURIGetParam(virURIPtr uri, const char *name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < uri->paramsCount; i++) {
|
||||
if (STREQ(uri->params[i].name, name))
|
||||
return uri->params[i].value;
|
||||
}
|
||||
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("Missing URI parameter '%s'"), name);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -62,4 +62,6 @@ void virURIFree(virURIPtr uri);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virURI, virURIFree);
|
||||
int virURIResolveAlias(virConfPtr conf, const char *alias, char **uri);
|
||||
|
||||
const char *virURIGetParam(virURIPtr uri, const char *name);
|
||||
|
||||
#define VIR_URI_SERVER(uri) ((uri) && (uri)->server ? (uri)->server : "localhost")
|
||||
|
Loading…
x
Reference in New Issue
Block a user