# HG changeset patch # User renatofilho # Date 1176411436 -3600 # Node ID 05e6ab23f892a8090f27aace50a19f71ec1a7a9d # Parent 7dacfb6cb42410315170ce5b3934783dbd738f58 [svn r543] fixed parse string diff -r 7dacfb6cb424 -r 05e6ab23f892 gmyth-stream/libgnomevfs2/modules/gmythstream-method.c --- a/gmyth-stream/libgnomevfs2/modules/gmythstream-method.c Thu Apr 12 21:28:37 2007 +0100 +++ b/gmyth-stream/libgnomevfs2/modules/gmythstream-method.c Thu Apr 12 21:57:16 2007 +0100 @@ -155,45 +155,56 @@ return; } -char* _parse_opt(char* opt) -{ - char** list = g_strsplit(opt, "opt=", 2); - char** opts = g_strsplit(list[1], "+", 32); - char* value = ""; - char* aux; - gint i = 0; - - for (aux = opts[0]; aux != NULL; aux = opts[++i]) - value = g_strdup_printf("%s %s", value, aux); - - g_free(aux); - g_strfreev(list); - g_strfreev(opts); - return value; -} - static UriArgs * _uri_parse_args (const GnomeVFSURI *uri) { - gchar *file = gnome_vfs_unescape_string (uri->text, NULL); - gchar **lst = g_strsplit (file, "?", 0); + + gchar *file; UriArgs *info = g_new0 (UriArgs, 1); - gint i = 1; + GSList *args = NULL; + gchar *c; + GString *entry; + gboolean open = FALSE; + gchar **prop; + GSList* walk; + gchar *uri_str = gnome_vfs_uri_to_string (uri, + GNOME_VFS_URI_HIDE_USER_NAME | + GNOME_VFS_URI_HIDE_PASSWORD | + GNOME_VFS_URI_HIDE_HOST_NAME | + GNOME_VFS_URI_HIDE_HOST_PORT | + GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD | + GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER); - gchar** prop = NULL; - prop = g_strsplit_set(lst[0], "/=", 3); + file = gnome_vfs_unescape_string (uri_str, NULL); + c = file; + //skip "/" + entry = g_string_new (""); + c = c + 1; + do { + if ((*c == '\"') || (*c == '\'')) { + open = !open; + } - info->file_name = g_strdup_printf ("%s://%s",\ - prop[1],prop[2]); - g_strfreev(prop); + if (((*c == '?') || (c + 1 == '\0')) && !open) { + args = g_slist_append (args, g_strdup (entry->str)); + entry = g_string_assign (entry, ""); + } else { + g_string_append_c (entry, *c); + } + c = c + 1; + } while (*c != '\0'); - gchar* walk; - for (walk = lst[1]; walk != NULL; walk = lst[++i]) + g_string_free (entry, TRUE); + + for (walk = args; walk != NULL; walk = walk->next) { - prop = g_strsplit(walk, "=", 2); + gchar *arg = (gchar *) walk->data; + prop = g_strsplit(arg, "=", 2); if (g_strv_length (prop) == 2) { - if (strcmp (prop[0], "mux") == 0) { + if (strcmp (prop[0], "file") == 0) { + info->file_name = g_strdup (prop[1]); + } else if (strcmp (prop[0], "mux") == 0) { info->mux = g_strdup (prop[1]); } else if (strcmp (prop[0], "vcodec") == 0) { info->vcodec = g_strdup (prop[1]); @@ -210,16 +221,16 @@ } else if (strcmp (prop[0], "height") == 0) { info->height = atoi (prop[1]); } else if (strcmp (prop[0], "opt") == 0) { - g_debug("DENTRO DE OPT: %s", walk); - char* v = _parse_opt(walk); - info->opt = g_strdup (v); + g_debug("DENTRO DE OPT: %s", arg); + //char* v = _parse_opt(walk); + info->opt = g_strdup (arg); } - } + } g_strfreev (prop); + g_free (arg); } - g_free (file); - g_strfreev (lst); + g_slist_free (args); return info; }