diff options
author | Dan Winship <danw@src.gnome.org> | 2003-06-20 23:32:01 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2003-06-20 23:32:01 +0800 |
commit | e586397c0569f0b5ed6b7764f1d2ff74fc26d9b3 (patch) | |
tree | ae8edcad1cf52e1cf49c3672e4638ef83ffc7488 /tools/killev.c | |
parent | c20675d2016a9f52da128d09ca03a46bc679e946 (diff) | |
download | gsoc2013-evolution-e586397c0569f0b5ed6b7764f1d2ff74fc26d9b3.tar.gz gsoc2013-evolution-e586397c0569f0b5ed6b7764f1d2ff74fc26d9b3.tar.zst gsoc2013-evolution-e586397c0569f0b5ed6b7764f1d2ff74fc26d9b3.zip |
clean this up a little and make it deal with "evolution" vs
* tools/killev.c (kill_component): clean this up a little and make
it deal with "evolution" vs "evolution-1.4"
svn path=/trunk/; revision=21499
Diffstat (limited to 'tools/killev.c')
-rw-r--r-- | tools/killev.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/tools/killev.c b/tools/killev.c index 6904b02243..0c735c0a19 100644 --- a/tools/killev.c +++ b/tools/killev.c @@ -84,36 +84,37 @@ kill_process (const char *proc_name, KillevComponent *comp) return TRUE; }; +static const char *patterns[] = { + "%s", "%.16s", "lt-%s", "lt-%.13s" +}; +static const int n_patterns = G_N_ELEMENTS (patterns); + static gboolean kill_component (gpointer key, gpointer value, gpointer data) { KillevComponent *comp = value; - char *exe_name; - - if (kill_process (comp->location, comp)) - return TRUE; - - exe_name = g_strdup_printf ("lt-%s", comp->location); - if (kill_process (exe_name, comp)) { - g_free (exe_name); - return TRUE; - } + char *base_name, *exe_name, *dash; + int i; - if (strlen (exe_name) > 16) { - exe_name[16] = '\0'; + base_name = g_strdup (comp->location); + try_again: + for (i = 0; i < n_patterns; i++) { + exe_name = g_strdup_printf (patterns[i], base_name); if (kill_process (exe_name, comp)) { - g_free (exe_name); + g_free (exe_name); + g_free (base_name); return TRUE; } + g_free (exe_name); } - g_free (exe_name); - if (strlen (comp->location) > 16) { - exe_name = g_strndup (comp->location, 16); - kill_process (exe_name, comp); - g_free (exe_name); + dash = strrchr (base_name, '-'); + if (dash && !strcmp (dash + 1, BASE_VERSION)) { + *dash = '\0'; + goto try_again; } + g_free (base_name); return TRUE; } |