GnuCash
5.6-150-g038405b370+
|
Files | |
file | gnc-uri-utils.h |
Utility functions for convert uri in separate components and back. | |
Macros | |
#define | GNC_DATAFILE_EXT ".gnucash" |
#define | GNC_LOGFILE_EXT ".log" |
Functions | |
gboolean | gnc_uri_is_uri (const gchar *uri) |
Checks if the given uri is a valid uri. More... | |
void | gnc_uri_get_components (const gchar *uri, gchar **scheme, gchar **hostname, gint32 *port, gchar **username, gchar **password, gchar **path) |
Converts a uri in separate components. More... | |
gchar * | gnc_uri_get_scheme (const gchar *uri) |
Extracts the scheme from a uri. More... | |
gchar * | gnc_uri_get_path (const gchar *uri) |
Extracts the path part from a uri. More... | |
gchar * | gnc_uri_create_uri (const gchar *scheme, const gchar *hostname, gint32 port, const gchar *username, const gchar *password, const gchar *path) |
Composes a normalized uri starting from its separate components. More... | |
gchar * | gnc_uri_normalize_uri (const gchar *uri, gboolean allow_password) |
Composes a normalized uri starting from any uri (filename, db spec,...). More... | |
gboolean | gnc_uri_is_known_scheme (const gchar *scheme) |
Checks if there is a backend that explicitly stated to handle the given scheme. More... | |
gboolean | gnc_uri_is_file_scheme (const gchar *scheme) |
Checks if the given scheme is used to refer to a file (as opposed to a network service like a database or web url) More... | |
gboolean | gnc_uri_is_file_uri (const gchar *uri) |
Checks if the given uri defines a file (as opposed to a network service like a database or web url) More... | |
gboolean | gnc_uri_targets_local_fs (const gchar *uri) |
Checks if the given uri is either a valid file uri or a local filesystem path. More... | |
gchar * | gnc_uri_add_extension (const gchar *uri, const gchar *extension) |
Adds an extension to the uri if: More... | |
gchar* gnc_uri_add_extension | ( | const gchar * | uri, |
const gchar * | extension | ||
) |
Adds an extension to the uri if:
uri | The uri to process |
extension | The extension to add if missing. Note that the extension is added verbatim, so if a dot should be added, this should be part of the extension. |
Definition at line 413 of file gnc-uri-utils.c.
gchar* gnc_uri_create_uri | ( | const gchar * | scheme, |
const gchar * | hostname, | ||
gint32 | port, | ||
const gchar * | username, | ||
const gchar * | password, | ||
const gchar * | path | ||
) |
Composes a normalized uri starting from its separate components.
The resulting uri will take either of these forms:
file:///some/absolute/path
(file could also be xml or sqlite) file://c:\some\windows\path
(file could also be xml or sqlite) scheme://
[user[:password]@]hostname[:port]/pathOnly the components that are provided will be inserted in the uri. However if no scheme has been provided, 'file' will be used as default scheme.
The function allocates memory for the uri. The calling function should free this memory with g_free the uri is no longer needed.
scheme | The scheme for this uri. If NULL,, 'file' will be used in the uri. |
hostname | The host name of the server to connect to. This will be ignored for the 'file' type schemes ('file', 'xml', 'sqlite'). |
port | An optional port to set o, the uri, or 0 if no port is to be set. This will be ignored for the 'file' type schemes ('file', 'xml', 'sqlite'). |
username | Optional user name to set in the uri or NULL otherwise. This will be ignored for the 'file' type schemes ('file', 'xml', 'sqlite'). |
password | Optional password to set in the uri or NULL otherwise. This will be ignored for the 'file' type schemes ('file', 'xml', 'sqlite'). |
path | The path to set in the uri. |
Definition at line 297 of file gnc-uri-utils.c.
void gnc_uri_get_components | ( | const gchar * | uri, |
gchar ** | scheme, | ||
gchar ** | hostname, | ||
gint32 * | port, | ||
gchar ** | username, | ||
gchar ** | password, | ||
gchar ** | path | ||
) |
Converts a uri in separate components.
The function allocates memory for each of the components that it finds in the uri. The calling function should free this memory with g_free when the items are no longer needed.
uri | The uri to convert |
scheme | The scheme for this uri. If the uri doesn't have an explicit scheme, NULL will be returned. |
hostname | The host name of the server to connect to. In case of the local file system path, NULL will be returned |
port | An optional port to connect to or 0 if the default port is to be used. For local filesystem path this is always 0 as well. |
username | Optional user name found in this uri or NULL if none is found. |
password | Optional password found in this uri or NULL if none is found. |
path | The path found in this uri. |
Definition at line 143 of file gnc-uri-utils.c.
gchar* gnc_uri_get_path | ( | const gchar * | uri | ) |
Extracts the path part from a uri.
The function allocates memory for the path. The calling function should free this memory with g_free if it no longer needs the string.
uri | The uri to extract the path part from |
Definition at line 276 of file gnc-uri-utils.c.
gchar* gnc_uri_get_scheme | ( | const gchar * | uri | ) |
Extracts the scheme from a uri.
The function allocates memory for the scheme. The calling function should free this memory with g_free if it no longer needs the string.
uri | The uri to extract the scheme from |
Definition at line 256 of file gnc-uri-utils.c.
gboolean gnc_uri_is_file_scheme | ( | const gchar * | scheme | ) |
Checks if the given scheme is used to refer to a file (as opposed to a network service like a database or web url)
scheme | The scheme to check |
Definition at line 90 of file gnc-uri-utils.c.
gboolean gnc_uri_is_file_uri | ( | const gchar * | uri | ) |
Checks if the given uri defines a file (as opposed to a network service like a database or web url)
uri | The uri to check |
Definition at line 101 of file gnc-uri-utils.c.
gboolean gnc_uri_is_known_scheme | ( | const gchar * | scheme | ) |
Checks if there is a backend that explicitly stated to handle the given scheme.
scheme | The scheme to check |
Definition at line 61 of file gnc-uri-utils.c.
gboolean gnc_uri_is_uri | ( | const gchar * | uri | ) |
Checks if the given uri is a valid uri.
A valid uri is defined by having at least a scheme and a path. If the uri is not referring to a file on the local file system a hostname should be set as well.
uri | The uri to check |
Definition at line 32 of file gnc-uri-utils.c.
gchar* gnc_uri_normalize_uri | ( | const gchar * | uri, |
gboolean | allow_password | ||
) |
Composes a normalized uri starting from any uri (filename, db spec,...).
The resulting uri will take either of these forms:
file:///some/absolute/path
('file' can also be xml or sqlite) file://c:\some\windows\path
('file' can also be xml or sqlite) scheme://
[user[:password]@]hostname[:port]/pathOnly the components that are provided will be inserted in the uri. The allow_password parameter controls if the password should be added to the returned uri when available. If no scheme has been provided, 'file' will be used as default scheme.
The function allocates memory for the uri. The calling function should free this memory with g_free the uri is no longer needed.
uri | The uri that should be converted into a normalized uri |
allow_password | If set to TRUE, the normalized uri and the input uri has a password, this passworld will also be set in the normalized uri. Otherwise no password will be set in the normalized uri. |
Definition at line 385 of file gnc-uri-utils.c.
gboolean gnc_uri_targets_local_fs | ( | const gchar * | uri | ) |
Checks if the given uri is either a valid file uri or a local filesystem path.
A valid file uri is defined by having a file targeting scheme ('file', 'xml' or 'sqlite3' are accepted) and a non-NULL path.
uri | The uri to check |
Definition at line 113 of file gnc-uri-utils.c.