GnuCash
2.6.99
|
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 | |
void | gnc_uri_get_components (const gchar *uri, gchar **protocol, gchar **hostname, gint32 *port, gchar **username, gchar **password, gchar **path) |
gchar * | gnc_uri_get_protocol (const gchar *uri) |
gchar * | gnc_uri_get_path (const gchar *uri) |
gchar * | gnc_uri_create_uri (const gchar *protocol, const gchar *hostname, gint32 port, const gchar *username, const gchar *password, const gchar *path) |
gchar * | gnc_uri_normalize_uri (const gchar *uri, gboolean allow_password) |
gboolean | gnc_uri_is_known_protocol (const gchar *protocol) |
gboolean | gnc_uri_is_file_protocol (const gchar *protocol) |
gboolean | gnc_uri_is_file_uri (const gchar *uri) |
gchar * | gnc_uri_add_extension (const gchar *uri, const gchar *extension) |
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 328 of file gnc-uri-utils.c.
gchar* gnc_uri_create_uri | ( | const gchar * | protocol, |
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) protocol://
[user[:password]@]hostname[:port]/pathOnly the components that are provided will be inserted in the uri. However if no protocol has been provided, 'file' will be used as default protocol.
The function allocates memory for the uri. The calling function should free this memory with g_free the uri is no longer needed.
protocol | The protocol 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 protocols ('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 protocols ('file', 'xml', 'sqlite'). |
username | Optional user name to set in the uri or NULL otherwise. This will be ignored for the 'file' type protocols ('file', 'xml', 'sqlite'). |
password | Optional password to set in the uri or NULL otherwise. This will be ignored for the 'file' type protocols ('file', 'xml', 'sqlite'). |
path | The path to set in the uri. |
Definition at line 237 of file gnc-uri-utils.c.
void gnc_uri_get_components | ( | const gchar * | uri, |
gchar ** | protocol, | ||
gchar ** | hostname, | ||
gint32 * | port, | ||
gchar ** | username, | ||
gchar ** | password, | ||
gchar ** | path | ||
) |
Converts a uri in separate components.
Uri's can take any of the following forms:
/some/filesystem/path
A simple file system path (unix style) c:\some\windows\path
A simple file system path (Windows style) proto://
[[username[:password]@]hostname[:port]]/path (universal uri)In the last form, anything in square brackets is optional.
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 if the items are no longer needed.
uri | The uri to convert |
protocol | The protocol for this uri. If the uri didn't have an explicit protocol, 'file' will be the assumed protocol and hence what will be returned. |
hostname | The host name of the server to connect to. In case of the 'file' protocol, this will be NULL |
port | An optional port to connect to or 0 if the default port is to be used. For the 'file' protocol 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. Note that if the protocol is a file based protocol, the path will be converted to an absolute path. |
Definition at line 82 of file gnc-uri-utils.c.
gchar* gnc_uri_get_path | ( | const gchar * | uri | ) |
Extracts the path part from a uri
Uri's can take any of the following forms:
/some/filesystem/path
A simple file system path (unix style) c:\some\windows\path
A simple file system path (Windows style) proto://
[[username[:password]@]hostname[:port]]/path (universal uri)In the last form, anything in square brackets is optional.
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 216 of file gnc-uri-utils.c.
gchar* gnc_uri_get_protocol | ( | const gchar * | uri | ) |
Extracts the protocol from a uri
Uri's can take any of the following forms:
/some/filesystem/path
A simple file system path (unix style) c:\some\windows\path
A simple file system path (Windows style) proto://
[[username[:password]@]hostname[:port]]/path (universal uri)In the last form, anything in square brackets is optional.
The function allocates memory for the protocol. The calling function should free this memory with g_free if it no longer needs the string.
uri | The uri to extract the protocol from |
Definition at line 196 of file gnc-uri-utils.c.
gboolean gnc_uri_is_file_protocol | ( | const gchar * | protocol | ) |
Checks if the given protocol is used to refer to a file (as opposed to a network service like a database or web url)
protocol | The protocol to check |
Definition at line 58 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 71 of file gnc-uri-utils.c.
gboolean gnc_uri_is_known_protocol | ( | const gchar * | protocol | ) |
Checks if there is a backend that explicitly stated to handle the given protocol.
protocol | The protocol to check |
Definition at line 33 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 could also be xml or sqlite) file://c:\some\windows\path
(file could also be xml or sqlite) protocol://
[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 protocol has been provided, 'file' will be used as default protocol.
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 schould 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 300 of file gnc-uri-utils.c.