[network-manager-openvpn] Use g_str_has_suffix instead of strcmp to compare extensions
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn] Use g_str_has_suffix instead of strcmp to compare extensions
- Date: Sat, 7 Feb 2015 11:57:08 +0000 (UTC)
commit 08517dc429040d9d16c2cfcfc2c76642b70384e3
Author: Pablo Castellano <pablog gnome org>
Date: Fri Oct 29 01:10:27 2010 +0200
Use g_str_has_suffix instead of strcmp to compare extensions
https://bugzilla.gnome.org/show_bug.cgi?id=626291
properties/auth-helpers.c | 7 ++++---
properties/nm-openvpn.c | 15 ++++-----------
2 files changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/properties/auth-helpers.c b/properties/auth-helpers.c
index e53f737..226149e 100644
--- a/properties/auth-helpers.c
+++ b/properties/auth-helpers.c
@@ -851,12 +851,13 @@ tls_default_filter (const GtkFileFilterInfo *filter_info, gpointer data)
if (!ext)
return FALSE;
- if (pkcs_allowed && !strcmp (ext, ".p12") && is_pkcs12 (filter_info->filename)) {
+ if (pkcs_allowed && g_str_has_suffix (ext, ".p12") && is_pkcs12 (filter_info->filename)) {
g_free (ext);
return TRUE;
}
- if (strcmp (ext, ".pem") && strcmp (ext, ".crt") && strcmp (ext, ".key") && strcmp (ext, ".cer")) {
+ if (!g_str_has_suffix (ext, ".pem") && !g_str_has_suffix (ext, ".crt") &&
+ !g_str_has_suffix (ext, ".key") && !g_str_has_suffix (ext, ".cer")) {
g_free (ext);
return FALSE;
}
@@ -940,7 +941,7 @@ sk_default_filter (const GtkFileFilterInfo *filter_info, gpointer data)
ext = g_ascii_strdown (p, -1);
if (!ext)
return FALSE;
- if (strcmp (ext, ".key")) {
+ if (!g_str_has_suffix (ext, ".key")) {
g_free (ext);
return FALSE;
}
diff --git a/properties/nm-openvpn.c b/properties/nm-openvpn.c
index b49fece..ba3c4ac 100644
--- a/properties/nm-openvpn.c
+++ b/properties/nm-openvpn.c
@@ -659,18 +659,11 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
char *ext;
ext = strrchr (path, '.');
- if (!ext) {
- g_set_error (error,
- OPENVPN_PLUGIN_UI_ERROR,
- OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_OPENVPN,
- "unknown OpenVPN file extension");
- goto out;
- }
- if ( strcmp (ext, ".ovpn")
- && strcmp (ext, ".conf")
- && strcmp (ext, ".cnf")
- && strcmp (ext, ".ovpntest")) { /* Special extension for testcases */
+ if (!ext || ( !g_str_has_suffix (ext, ".ovpn")
+ && !g_str_has_suffix (ext, ".conf")
+ && !g_str_has_suffix (ext, ".cnf")
+ && !g_str_has_suffix (ext, ".ovpntest"))) { /* Special extension for testcases */
g_set_error (error,
OPENVPN_PLUGIN_UI_ERROR,
OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_OPENVPN,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]