35 gboolean is_known_proto = FALSE;
39 for ( node = known_proto_list; node != NULL; node = node->next )
41 gchar *known_proto = node->data;
42 if ( !g_ascii_strcasecmp (protocol, known_proto) )
44 is_known_proto = TRUE;
49 g_list_free (known_proto_list);
50 return is_known_proto;
60 if ( !g_ascii_strcasecmp (protocol,
"mysql") ||
61 !g_ascii_strcasecmp (protocol,
"postgres")
91 gchar *url = NULL, *tmpusername = NULL, *tmphostname = NULL;
92 gchar *delimiter = NULL;
101 g_return_if_fail( uri != NULL && strlen (uri) > 0);
103 splituri = g_strsplit ( uri,
"://", 2 );
104 if ( splituri[1] == NULL )
107 *protocol = g_strdup (
"file" );
108 *path = g_strdup ( splituri[0] );
109 g_strfreev ( splituri );
114 *protocol = g_strdup ( splituri[0] );
129 *path = g_strdup ( splituri[1] );
130 g_strfreev ( splituri );
137 url = g_strdup (splituri[1]);
138 g_strfreev ( splituri );
143 delimiter = g_strrstr ( url,
"@" );
144 if ( delimiter != NULL )
149 tmphostname = delimiter + 1;
154 delimiter = g_strstr_len ( tmpusername, -1,
":" );
155 if ( delimiter != NULL )
159 *password = g_strdup ( (
const gchar*)(delimiter + 1) );
161 *username = g_strdup ( (
const gchar*)tmpusername );
170 delimiter = g_strstr_len ( tmphostname, -1,
"/" );
171 if ( delimiter != NULL )
177 *path = g_strdup ( (
const gchar*)(delimiter + 1) );
181 delimiter = g_strstr_len ( tmphostname, -1,
":" );
182 if ( delimiter != NULL )
185 *port = g_ascii_strtoll ( delimiter + 1, NULL, 0 );
188 *hostname = g_strdup ( (
const gchar*)tmphostname );
198 gchar *protocol = NULL;
199 gchar *hostname = NULL;
201 gchar *username = NULL;
202 gchar *password = NULL;
206 &username, &password, &path );
218 gchar *protocol = NULL;
219 gchar *hostname = NULL;
221 gchar *username = NULL;
222 gchar *password = NULL;
226 &username, &password, &path );
238 const gchar *hostname,
240 const gchar *username,
241 const gchar *password,
244 gchar *userpass = NULL, *portstr = NULL, *uri = NULL;
246 g_return_val_if_fail( path != 0, NULL );
258 abs_path = g_strdup ( path );
261 if ( protocol == NULL )
262 uri = g_strdup_printf (
"file://%s", abs_path );
264 uri = g_strdup_printf (
"%s://%s", protocol, abs_path );
272 g_return_val_if_fail( hostname != 0, NULL );
274 if ( username != NULL && *username )
276 if ( password != NULL && *password )
277 userpass = g_strdup_printf (
"%s:%s@", username, password );
279 userpass = g_strdup_printf (
"%s@", username );
282 userpass = g_strdup (
"" );
285 portstr = g_strdup_printf (
":%d", port );
287 portstr = g_strdup (
"" );
291 uri = g_strconcat ( protocol,
"://", userpass, hostname, portstr,
"/", path, NULL );
302 gchar *protocol = NULL;
303 gchar *hostname = NULL;
305 gchar *username = NULL;
306 gchar *password = NULL;
308 gchar *newuri = NULL;
311 &username, &password, &path );
314 username, password, path);
317 username, NULL, path);
330 g_return_val_if_fail( uri != 0, NULL );
336 return g_strdup( uri );
339 if ( g_str_has_suffix( uri, extension ) )
340 return g_strdup( uri );
343 return g_strconcat( uri, extension, NULL );
Encapsulates a connection to a backend (persistent store)
gboolean gnc_uri_is_file_protocol(const gchar *protocol)
gboolean gnc_uri_is_file_uri(const gchar *uri)
gchar * gnc_uri_get_path(const gchar *uri)
gboolean gnc_uri_is_known_protocol(const gchar *protocol)
gchar * gnc_resolve_file_path(const gchar *filefrag)
Create an absolute path when given a relative path; otherwise return the argument.
gchar * gnc_uri_normalize_uri(const gchar *uri, gboolean allow_password)
void gnc_uri_get_components(const gchar *uri, gchar **protocol, gchar **hostname, gint32 *port, gchar **username, gchar **password, gchar **path)
gchar * gnc_uri_add_extension(const gchar *uri, const gchar *extension)
gchar * gnc_uri_create_uri(const gchar *protocol, const gchar *hostname, gint32 port, const gchar *username, const gchar *password, const gchar *path)
GList * qof_backend_get_registered_access_method_list(void)
Utility functions for convert uri in separate components and back.
File path resolution utility functions.
gchar * gnc_uri_get_protocol(const gchar *uri)