1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
$NetBSD: patch-ay,v 1.3 2002/05/05 22:52:12 martin Exp $
--- libgnome/gnome-url.c.orig Thu Jan 10 23:03:17 2002
+++ libgnome/gnome-url.c Mon May 6 00:06:38 2002
@@ -80,6 +80,8 @@
return default_handler;
}
+static int gnome_url_show_with_handler (const gchar *url, const gchar *template);
+
/**
* gnome_url_show
* @url: URL to show
@@ -105,11 +107,9 @@
void
gnome_url_show(const gchar *url)
{
- gint i;
gchar *pos, *template;
gboolean free_template = FALSE;
- int argc;
- char **argv;
+ int status;
g_return_if_fail (url != NULL);
pos = strchr (url, ':');
@@ -135,12 +135,26 @@
} else /* no : ? -- this shouldn't happen. Use default handler */
template = gnome_url_default_handler (NULL);
+ status = gnome_url_show_with_handler (url, template);
+ if (status == -1 && free_template)
+ gnome_url_show_with_handler (url, gnome_url_default_handler (NULL));
+
+ if (free_template)
+ g_free (template);
+}
+
+static int
+gnome_url_show_with_handler (const gchar *url, const gchar *template)
+{
+ int argc, i, status;
+ char **argv;
+
/* we use a popt function as it does exactly what we want to do and
gnome already uses popt */
if(poptParseArgvString(template, &argc, &argv) != 0) {
/* can't parse */
g_warning("Parse error of '%s'", template);
- return;
+ return -1;
}
/* we can just replace the entry in the array since the
@@ -154,13 +168,12 @@
/* use execute async, and not the shell, shell is evil and a
* security hole */
- gnome_execute_async (NULL, argc, argv);
-
- if (free_template)
- g_free (template);
+ status = gnome_execute_async (NULL, argc, argv);
/* the way the poptParseArgvString works is that the entire thing
* is allocated as one buffer, so just free will suffice, also
* it must be free and not g_free */
free(argv);
+
+ return status;
}
|