Function

GLibUrisplit_network

Declaration

gboolean
g_uri_split_network (
  const gchar* uri_string,
  GUriFlags flags,
  gchar** scheme,
  gchar** host,
  gint* port,
  GError** error
)

Description

Parses uri_string (which must be an [absolute URI][relative-absolute-uris]) according to flags, and returns the pieces relevant to connecting to a host. See the documentation for g_uri_split() for more details; this is mostly a wrapper around that function with simpler arguments. However, it will return an error if uri_string is a relative URI, or does not contain a hostname component.

Available since:2.66

Parameters

uri_string

Type: const gchar*

A string containing an absolute URI.

The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
flags

Type: GUriFlags

Flags for parsing uri_string.

scheme

Type: gchar**

On return, contains the scheme (converted to lowercase), or NULL.

The argument will be set by the function.
The argument can be set to NULL by the function.
The argument can be NULL.
The called function takes ownership of the data, and is responsible for freeing it.
The value is a NUL terminated UTF-8 string.
host

Type: gchar**

On return, contains the host, or NULL.

The argument will be set by the function.
The argument can be set to NULL by the function.
The argument can be NULL.
The called function takes ownership of the data, and is responsible for freeing it.
The value is a NUL terminated UTF-8 string.
port

Type: gint*

On return, contains the port, or -1

The argument will be set by the function.
The argument can be NULL.
error

Type: GError **

The return location for an error.

The argument can be NULL.
The argument will be set to NULL by the function if there are no errors.
In case of error, the argument will be set and the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: gboolean

TRUE if uri_string parsed successfully, FALSE on error.