mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
remote: split out function for parsing URI scheme
The remoteSplitURISCheme method will be needed by source files beyond the remote driver client. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
9949d9b28f
commit
849de2b844
@ -165,31 +165,6 @@ static void make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapsho
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/* Helper functions for remoteOpen. */
|
||||
static int remoteSplitURIScheme(virURIPtr uri,
|
||||
char **driver,
|
||||
char **transport)
|
||||
{
|
||||
char *p = strchr(uri->scheme, '+');
|
||||
|
||||
*driver = *transport = NULL;
|
||||
|
||||
if (p)
|
||||
*driver = g_strndup(uri->scheme, p - uri->scheme);
|
||||
else
|
||||
*driver = g_strdup(uri->scheme);
|
||||
|
||||
if (p) {
|
||||
*transport = g_strdup(p + 1);
|
||||
|
||||
p = *transport;
|
||||
while (*p) {
|
||||
*p = g_ascii_tolower(*p);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
|
@ -37,3 +37,31 @@ VIR_ENUM_IMPL(remoteDriverMode,
|
||||
"auto",
|
||||
"legacy",
|
||||
"direct");
|
||||
|
||||
|
||||
int
|
||||
remoteSplitURIScheme(virURIPtr uri,
|
||||
char **driver,
|
||||
char **transport)
|
||||
{
|
||||
char *p = strchr(uri->scheme, '+');
|
||||
|
||||
*driver = *transport = NULL;
|
||||
|
||||
if (p)
|
||||
*driver = g_strndup(uri->scheme, p - uri->scheme);
|
||||
else
|
||||
*driver = g_strdup(uri->scheme);
|
||||
|
||||
if (p) {
|
||||
*transport = g_strdup(p + 1);
|
||||
|
||||
p = *transport;
|
||||
while (*p) {
|
||||
*p = g_ascii_tolower(*p);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "virenum.h"
|
||||
#include "viruri.h"
|
||||
|
||||
typedef enum {
|
||||
REMOTE_DRIVER_TRANSPORT_TLS,
|
||||
@ -48,3 +49,8 @@ typedef enum {
|
||||
} remoteDriverMode;
|
||||
|
||||
VIR_ENUM_DECL(remoteDriverMode);
|
||||
|
||||
int
|
||||
remoteSplitURIScheme(virURIPtr uri,
|
||||
char **driver,
|
||||
char **transport);
|
||||
|
Loading…
Reference in New Issue
Block a user