[PATCH] network-manager-vpnc: properties: replace pcf_file_* by glib functions



Replace pcf_file_* functions by the corresponding functions in glib.

Signed-off-by: Murilo Opsfelder Araujo <muriloo linux vnet ibm com>
---
 properties/Makefile.am |    2 -
 properties/nm-vpnc.c   |  201 ++++++++++++++++------------------
 properties/pcf-file.c  |  287 ------------------------------------------------
 properties/pcf-file.h  |   56 ----------
 4 files changed, 95 insertions(+), 451 deletions(-)
 delete mode 100644 properties/pcf-file.c
 delete mode 100644 properties/pcf-file.h

diff --git a/properties/Makefile.am b/properties/Makefile.am
index c7d17ad..3d83a55 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -6,8 +6,6 @@ plugindir = $(libdir)/NetworkManager
 plugin_LTLIBRARIES = libnm-vpnc-properties.la

 libnm_vpnc_properties_la_SOURCES = \
-	pcf-file.c \
-	pcf-file.h \
 	nm-vpnc.c \
 	nm-vpnc.h

diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index 34f4fc0..81025d8 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -48,7 +48,6 @@
 #include <nm-setting-ip4-config.h>

 #include "src/nm-vpnc-service.h"
-#include "pcf-file.h"
 #include "nm-vpnc.h"

 #define VPNC_PLUGIN_NAME    _("Cisco Compatible VPN (vpnc)")
@@ -1161,15 +1160,17 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 	NMConnection *connection;
 	NMSettingConnection *s_con;
 	NMSettingVPN *s_vpn;
-	GHashTable *pcf;
-	const char *buf;
+	NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
+	GKeyFile *keyfile;
+	GKeyFileFlags keyfile_flags;
+	char *buf;
 	gboolean bool_value;
 	NMSettingIP4Config *s_ip4;
 	gint val;
-	gboolean found;

-	pcf = pcf_file_load (path);
-	if (!pcf) {
+	keyfile = g_key_file_new ();
+	keyfile_flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
+	if (!g_key_file_load_from_file (keyfile, path, keyfile_flags, error)) {
 		g_set_error (error, 0, 0, "does not look like a %s VPN connection (parse failed)",
 		             VPNC_PLUGIN_NAME);
 		return NULL;
@@ -1187,7 +1188,8 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 	nm_connection_add_setting (connection, NM_SETTING (s_ip4));

 	/* Gateway */
-	if (pcf_file_lookup_string (pcf, "main", "Host", &buf))
+	buf = g_key_file_get_string (keyfile, "main", "Host", error);
+	if (buf)
 		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_GATEWAY, buf);
 	else {
 		g_set_error (error, 0, 0, "does not look like a %s VPN connection (no Host)",
@@ -1197,7 +1199,8 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 	}

 	/* Group name */
-	if (pcf_file_lookup_string (pcf, "main", "GroupName", &buf))
+	buf = g_key_file_get_string (keyfile, "main", "GroupName", error);
+	if (buf)
 		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_ID, buf);
 	else {
 		g_set_error (error, 0, 0, "does not look like a %s VPN connection (no GroupName)",
@@ -1209,13 +1212,16 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 	/* Optional settings */

 	/* Connection name */
-	if (pcf_file_lookup_string (pcf, "main", "Description", &buf))
+	buf = g_key_file_get_string (keyfile, "main", "Description", NULL);
+	if (buf)
 		g_object_set (s_con, NM_SETTING_CONNECTION_ID, buf, NULL);

-	if (pcf_file_lookup_string (pcf, "main", "UserName", &buf))
+	buf = g_key_file_get_string (keyfile, "main", "Username", NULL);
+	if (buf)
 		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_XAUTH_USER, buf);

-	if (pcf_file_lookup_string (pcf, "main", "UserPassword", &buf)) {
+	buf = g_key_file_get_string (keyfile, "main", "UserPassword", NULL);
+	if (buf) {
 		nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD, buf);
 		nm_setting_set_secret_flags (NM_SETTING (s_vpn),
 		                             NM_VPNC_KEY_XAUTH_PASSWORD,
@@ -1223,23 +1229,21 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 		                             NULL);
 	}

-	if (pcf_file_lookup_bool (pcf, "main", "SaveUserPassword", &bool_value)) {
-		NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
-
-		if (bool_value) {
-			nm_setting_vpn_add_data_item (s_vpn,
-			                              NM_VPNC_KEY_XAUTH_PASSWORD_TYPE,
-			                              NM_VPNC_PW_TYPE_SAVE);
-		} else
-			flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED;
-
-		nm_setting_set_secret_flags (NM_SETTING (s_vpn),
-			                         NM_VPNC_KEY_XAUTH_PASSWORD,
-			                         flags,
-			                         NULL);
-	}
+	bool_value = g_key_file_get_boolean (keyfile, "main", "SaveUserPassword", NULL);
+	flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
+	if (bool_value)
+		nm_setting_vpn_add_data_item (s_vpn,
+					NM_VPNC_KEY_XAUTH_PASSWORD_TYPE,
+					NM_VPNC_PW_TYPE_SAVE);
+	else
+		flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED;
+	nm_setting_set_secret_flags (NM_SETTING (s_vpn),
+					NM_VPNC_KEY_XAUTH_PASSWORD,
+					flags,
+					NULL);

-	if (pcf_file_lookup_string (pcf, "main", "GroupPwd", &buf)) {
+	buf = g_key_file_get_string (keyfile, "main", "GroupPwd", NULL);
+	if (buf) {
 		nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_SECRET, buf);
 		nm_setting_set_secret_flags (NM_SETTING (s_vpn),
 		                             NM_VPNC_KEY_SECRET,
@@ -1247,7 +1251,8 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 		                             NULL);
 	} else {
 		/* Handle encrypted passwords */
-		if (pcf_file_lookup_string (pcf, "main", "enc_GroupPwd", &buf)) {
+		buf = g_key_file_get_string (keyfile, "main", "enc_GroupPwd", NULL);
+		if (buf) {
 			char *decrypted;

 			decrypted = decrypt_cisco_key (buf);
@@ -1265,31 +1270,22 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 	}

 	/* Group Password Flags */
-	if (pcf_file_lookup_bool (pcf, "main", "X-NM-SaveGroupPassword", &bool_value)) {
-		NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
-
-		if (bool_value) {
-			nm_setting_vpn_add_data_item (s_vpn,
-			                              NM_VPNC_KEY_SECRET_TYPE,
-			                              NM_VPNC_PW_TYPE_SAVE);
-		} else
-			flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED;
-
-		nm_setting_set_secret_flags (NM_SETTING (s_vpn), NM_VPNC_KEY_SECRET, flags, NULL);
-	} else {
-		/* If the key isn't present, assume "saved" */
-		nm_setting_vpn_add_data_item (s_vpn,
-		                              NM_VPNC_KEY_SECRET_TYPE,
-		                              NM_VPNC_PW_TYPE_SAVE);
-	}
+	bool_value = g_key_file_get_boolean (keyfile, "main", "X-NM-SaveGroupPassword", NULL);
+	flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
+	nm_setting_vpn_add_data_item (s_vpn,
+				NM_VPNC_KEY_SECRET_TYPE,
+				NM_VPNC_PW_TYPE_SAVE);
+	if (!bool_value)
+		flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED;
+	nm_setting_set_secret_flags (NM_SETTING (s_vpn), NM_VPNC_KEY_SECRET, flags, NULL);

-	if (pcf_file_lookup_string (pcf, "main", "NTDomain", &buf))
+	buf = g_key_file_get_string (keyfile, "main", "NTDomain", NULL);
+	if (buf)
 		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DOMAIN, buf);

-	if (pcf_file_lookup_bool (pcf, "main", "SingleDES", &bool_value)) {
-		if (bool_value)
-			nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_SINGLE_DES, "yes");
-	}
+	bool_value = g_key_file_get_boolean (keyfile, "main", "SingleDES", NULL);
+	if (bool_value)
+		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_SINGLE_DES, "yes");

 	/* Disable all NAT Traversal if explicit EnableNat=0 exists, otherwise
 	 * default to NAT-T which is newer and standardized.  If EnableNat=1, then
@@ -1302,46 +1298,42 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 	                              NM_VPNC_KEY_NAT_TRAVERSAL_MODE,
 	                              NM_VPNC_NATT_MODE_CISCO);

-	if (pcf_file_lookup_bool (pcf, "main", "EnableNat", &bool_value)) {
-		if (bool_value) {
-			gboolean natt = FALSE, force_natt = FALSE;
-
-			if (!pcf_file_lookup_bool (pcf, "main", "X-NM-Use-NAT-T", &natt))
-				natt = FALSE;
-			if (!pcf_file_lookup_bool (pcf, "main", "X-NM-Force-NAT-T", &force_natt))
-				force_natt = FALSE;
-
-			/* force-natt takes precence over plain natt */
-			if (force_natt) {
-				nm_setting_vpn_add_data_item (s_vpn,
-				                              NM_VPNC_KEY_NAT_TRAVERSAL_MODE,
-				                              NM_VPNC_NATT_MODE_NATT_ALWAYS);
-			} else if (natt) {
-				nm_setting_vpn_add_data_item (s_vpn,
-				                              NM_VPNC_KEY_NAT_TRAVERSAL_MODE,
-				                              NM_VPNC_NATT_MODE_NATT);
-			}
-		} else {
+	bool_value = g_key_file_get_boolean (keyfile, "main", "EnableNat", NULL);
+	if (bool_value) {
+		gboolean natt = FALSE;
+		gboolean force_natt = FALSE;
+
+		natt = g_key_file_get_boolean (keyfile, "main", "X-NM-Use-NAT-T", NULL);
+		force_natt = g_key_file_get_boolean (keyfile, "main", "X-NM-Force-NAT-T", NULL);
+
+		/* force-natt takes precence over plain natt */
+		if (force_natt)
 			nm_setting_vpn_add_data_item (s_vpn,
-			                              NM_VPNC_KEY_NAT_TRAVERSAL_MODE,
-			                              NM_VPNC_NATT_MODE_NONE);
-		}
+						NM_VPNC_KEY_NAT_TRAVERSAL_MODE,
+						NM_VPNC_NATT_MODE_NATT_ALWAYS);
+		else if (natt)
+			nm_setting_vpn_add_data_item (s_vpn,
+						NM_VPNC_KEY_NAT_TRAVERSAL_MODE,
+						NM_VPNC_NATT_MODE_NATT);
+	} else {
+		nm_setting_vpn_add_data_item (s_vpn,
+					NM_VPNC_KEY_NAT_TRAVERSAL_MODE,
+					NM_VPNC_NATT_MODE_NONE);
 	}

-	if (pcf_file_lookup_int (pcf, "main", "PeerTimeout", &val)) {
-		if ((val == 0) || ((val >= 10) && (val <= 86400))) {
-			char *tmp = g_strdup_printf ("%d", (gint) val);
-			nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DPD_IDLE_TIMEOUT, tmp);
-			g_free (tmp);
-		}
+	val = g_key_file_get_integer (keyfile, "main", "PeerTimeout", NULL);
+	if ((val == 0) || ((val >= 10) && (val <= 86400))) {
+		char *tmp = g_strdup_printf ("%d", (gint) val);
+		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DPD_IDLE_TIMEOUT, tmp);
+		g_free (tmp);
 	}

-	if (pcf_file_lookup_bool (pcf, "main", "EnableLocalLAN", &bool_value)) {
-		if (bool_value)
-			g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, TRUE, NULL);
-	}
+	bool_value = g_key_file_get_boolean (keyfile, "main", "EnableLocalLAN", NULL);
+	if (bool_value)
+		g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, TRUE, NULL);

-	if (pcf_file_lookup_string (pcf, "main", "DHGroup", &buf)) {
+	buf = g_key_file_get_string (keyfile, "main", "DHGroup", NULL);
+	if (buf) {
 		if (!strcmp (buf, "1") || !strcmp (buf, "2") || !strcmp (buf, "5")) {
 			char *tmp;
 			tmp = g_strdup_printf ("dh%s", buf);
@@ -1350,42 +1342,39 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 		}
 	}

-	if (pcf_file_lookup_string (pcf, "main", "X-NM-Routes", &buf))
+	buf = g_key_file_get_string (keyfile, "main", "X-NM-Routes", NULL);
+	if (buf)
 		add_routes (s_ip4, buf);

-	if (pcf_file_lookup_int (pcf, "main", "TunnelingMode", &val)) {
-		/* If applicable, put up warning that TCP tunneling will be disabled */
-
-		if (val == 1) {
-			GtkWidget *dialog;
-			char *basename;
-
-			basename = g_path_get_basename (path);
-			dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
-			                                 GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
-			                                 _("TCP tunneling not supported"));
-			gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-			                                          _("The VPN settings file '%s' specifies that VPN traffic should be tunneled through TCP which is currently not supported in the vpnc software.\n\nThe connection can still be created, with TCP tunneling disabled, however it may not work as expected."), basename);
-			g_free (basename);
-			gtk_dialog_run (GTK_DIALOG (dialog));
-			gtk_widget_destroy (dialog);
-		}
+	val = g_key_file_get_integer (keyfile, "main", "TunnelingMode", error);
+	/* If applicable, put up warning that TCP tunneling will be disabled */
+	if (val == 1) {
+		GtkWidget *dialog;
+		char *basename;
+
+		basename = g_path_get_basename (path);
+		dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+							GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
+							_("TCP tunneling not supported"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+								_("The VPN settings file '%s' specifies that VPN traffic should be tunneled through TCP which is currently not supported in the vpnc software.\n\nThe connection can still be created, with TCP tunneling disabled, however it may not work as expected."), basename);
+		g_free (basename);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
 	}

 	/* UseLegacyIKEPort=0 uses dynamic source IKE port instead of 500.
 	 * http://www.cisco.com/en/US/products/sw/secursw/ps2308/products_administration_guide_chapter09186a008015cfdc.html#1192555
 	 * See also: http://support.microsoft.com/kb/928310
 	 */
-	found = pcf_file_lookup_int (pcf, "main", "UseLegacyIKEPort", &val);
-	if (!found || val != 0) {
+	val = g_key_file_get_integer (keyfile, "main", "UseLegacyIKEPort", error);
+	if (error || val != 0) {
 		char *tmp;
 		tmp = g_strdup_printf ("%d", (gint) NM_VPNC_LOCAL_PORT_DEFAULT); /* Use default vpnc local port: 500 */
 		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_LOCAL_PORT, tmp);
 		g_free (tmp);
 	}

-	g_hash_table_destroy (pcf);
-
 	return connection;
 }

diff --git a/properties/pcf-file.c b/properties/pcf-file.c
deleted file mode 100644
index b835b6c..0000000
--- a/properties/pcf-file.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager -- Network link manager
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2005 - 2008 Red Hat, Inc.
- * (C) Copyright 2007 - 2008 Novell, Inc.
- */
-
-/* See the following link for more information on PCF file format and keys:
- *
- * http://www.cisco.com/en/US/products/sw/secursw/ps2308/products_administration_guide_chapter09186a00800bd98d.html#wp1169242
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <ctype.h>
-#include <stdlib.h>
-
-#include "pcf-file.h"
-
-static void
-pcf_entry_free (PcfEntry *entry)
-{
-	if (entry) {
-		g_free (entry->key);
-		g_free (entry->value);
-		g_free (entry);
-	}
-}
-
-/*
-  The main reader loop here is based on the simple .ini file
-  parser from avahi/avahi-daemon/ini-file-parser.c
-*/
-
-GHashTable *
-pcf_file_load (const char *fname)
-{
-	FILE *fo;
-	unsigned line;
-    GHashTable *pcf;
-	GHashTable *group = NULL;
-    -    g_return_val_if_fail (fname != NULL, NULL);
-
-    if (!(fo = fopen (fname, "r"))) {
-        g_warning ("Failed to open file '%s': %s", fname, strerror (errno));
-        return NULL;
-    }
-
-	pcf = g_hash_table_new_full (g_str_hash, g_str_equal,
-								 g_free,
-								 (GDestroyNotify) g_hash_table_destroy);
-
-    line = 0;
-    while (!feof (fo)) {
-        char ln[1024]; /* 4x what we think to allow for possible UTF-8 conversion */
-        char *s, *e;
-        -        if (!(fgets (ln, sizeof (ln) / 4, fo)))
-            break;
-
-        line++;
-
-		if (!g_utf8_validate (ln, -1, NULL)) {
-			char *tmp;
-			GError *error = NULL;
-
-			tmp = g_locale_to_utf8 (ln, -1, NULL, NULL, &error);
-			if (error) {
-				/* ignore the error; leave 'ln' alone.  We tried. */
-				g_error_free (error);
-			} else {
-				g_assert (tmp);
-				strcpy (ln, tmp);  /* update ln with the UTF-8 safe text */
-			}
-			g_free (tmp);
-		}
-
-        s = ln + strspn (ln, " \t");
-        s[strcspn (s, "\r\n")] = 0;
-
-        /* Skip comments and empty lines */
-        if (*s == ';' || *s == 0)
-            continue;
-
-        if (*s == '[') {
-            /* new group */
-            -            if (!(e = strchr (s, ']'))) {
-                g_warning ("Unclosed group header in %s:%u: <%s>", fname, line, s);
-                goto fail;
-            }
-
-            *e = 0;
-
-			group = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
-										   (GDestroyNotify) pcf_entry_free);
-
-			g_hash_table_insert (pcf, g_utf8_strdown (s+1, -1), group);
-        } else {
-			PcfEntry *entry;
-			char *key;
-
-            /* Normal assignment */
-            if (!(e = strchr (s, '='))) {
-                g_warning ("Missing assignment in %s:%u: <%s>", fname, line, s);
-                goto fail;
-            }
-            -            if (!group) {
-                g_warning ("Assignment outside group in %s:%u <%s>", fname, line, s);
-                goto fail;
-            }
-            -            /* Split the key and the value */
-            *(e++) = 0;
-
-			entry = g_new (PcfEntry, 1);
-			entry->value = g_strdup (g_strstrip (e));
-
-			if (*s == '!') {
-				key = g_utf8_strdown (s+1, -1);
-				entry->read_only = TRUE;
-			} else {
-				key = g_utf8_strdown (s, -1);
-				entry->read_only = FALSE;
-			}
-
-			entry->key = g_strdup (g_strstrip (key));
-			g_free (key);
-			g_hash_table_insert (group, entry->key, entry);
-        }
-    }
-
-    /* Contains a main section? */
-    if (!g_hash_table_lookup (pcf, "main"))
-        goto fail;
-    -    fclose (fo);
-        -    return pcf;
-
-fail:
-
-    if (fo)
-        fclose (fo);
-
-    if (pcf)
-        g_hash_table_destroy (pcf);
-
-    return NULL;
-}
-
-PcfEntry *
-pcf_file_lookup (GHashTable *pcf_file,
-                 const char *group,
-                 const char *key)
-{
-	gpointer section;
-	PcfEntry *entry = NULL;
-	char *group_lower = NULL;
-	char *key_lower = NULL;
-
-	g_return_val_if_fail (pcf_file != NULL, NULL);
-	g_return_val_if_fail (group != NULL, NULL);
-	g_return_val_if_fail (key != NULL, NULL);
-
-	group_lower = g_utf8_strdown (group, -1);
-	section = g_hash_table_lookup (pcf_file, group_lower);
-	if (section) {
-		key_lower = g_utf8_strdown (key, -1);
-		entry = (PcfEntry *) g_hash_table_lookup ((GHashTable *) section, key_lower);
-	}
-
-	g_free (group_lower);
-	g_free (key_lower);
-
-	return entry;
-}
-
-gboolean
-pcf_file_lookup_string (GHashTable *pcf_file,
-                        const char *group,
-                        const char *key,
-                        const char **value)
-{
-	PcfEntry *entry;
-
-	g_return_val_if_fail (pcf_file != NULL, FALSE);
-	g_return_val_if_fail (group != NULL, FALSE);
-	g_return_val_if_fail (key != NULL, FALSE);
-	g_return_val_if_fail (value != NULL, FALSE);
-
-	*value = NULL;
-	entry = pcf_file_lookup (pcf_file, group, key);
-	if (!entry || !entry->value || !strlen (entry->value))
-		return FALSE;
-
-	*value = entry->value;
-	return TRUE;
-}
-
-gboolean
-pcf_file_lookup_bool (GHashTable *pcf_file,
-                      const char *group,
-                      const char *key,
-                      gboolean *value)
-{
-	const char *buf = NULL;
-	gboolean success = FALSE;
-
-	g_return_val_if_fail (pcf_file != NULL, FALSE);
-	g_return_val_if_fail (group != NULL, FALSE);
-	g_return_val_if_fail (key != NULL, FALSE);
-	g_return_val_if_fail (value != NULL, FALSE);
-
-	*value = FALSE;
-	if (!pcf_file_lookup_string (pcf_file, group, key, &buf))
-		return FALSE;
-
-	if (strlen (buf) == 1) {
-		if (strcmp (buf, "1") == 0) {
-			*value = TRUE;
-			success = TRUE;
-		} else if (strcmp (buf, "0") == 0) {
-			*value = FALSE;
-			success = TRUE;
-		}
-	} else {
-		if (   !strncasecmp (buf, "yes", 3)
-		    || !strncasecmp (buf, "true", 4)) {
-			*value = TRUE;
-			success = TRUE;
-		} else if (   !strncasecmp (buf, "no", 2)
-		           || !strncasecmp (buf, "false", 5)) {
-			*value = FALSE;
-			success = TRUE;
-		}
-	}
-
-	return success;
-}
-
-gboolean
-pcf_file_lookup_int (GHashTable *pcf_file,
-                     const char *group,
-                     const char *key,
-                     gint *value)
-{
-	const char *buf = NULL;
-	long int tmp;
-
-	g_return_val_if_fail (pcf_file != NULL, FALSE);
-	g_return_val_if_fail (group != NULL, FALSE);
-	g_return_val_if_fail (key != NULL, FALSE);
-	g_return_val_if_fail (value != NULL, FALSE);
-
-	*value = 0;
-	if (!pcf_file_lookup_string (pcf_file, group, key, &buf))
-		return FALSE;
-
-	errno = 0;
-	tmp = strtol (buf, NULL, 10);
-	if ((errno == 0) && (tmp > G_MININT) && (tmp < G_MAXINT)) {
-		*value = (gint) tmp;
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
diff --git a/properties/pcf-file.h b/properties/pcf-file.h
deleted file mode 100644
index bee4e98..0000000
--- a/properties/pcf-file.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager -- Network link manager
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2005 - 2008 Red Hat, Inc.
- * (C) Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef PCF_FILE_H
-#define PCF_FILE_H
-
-#include <glib.h>
-
-typedef struct PcfEntry PcfEntry;
-
-struct PcfEntry {
-	char *key;
-	char *value;
-	gboolean read_only;
-};
-
-GHashTable  *pcf_file_load        (const char *fname);
-PcfEntry    *pcf_file_lookup      (GHashTable *pcf_file,
-                                   const char *group,
-                                   const char *key);
-
-gboolean pcf_file_lookup_string (GHashTable *pcf_file,
-                                 const char *group,
-                                 const char *key,
-                                 const char **value);
-
-gboolean pcf_file_lookup_bool (GHashTable *pcf_file,
-                               const char *group,
-                               const char *key,
-                               gboolean *value);
-
-gboolean pcf_file_lookup_int (GHashTable *pcf_file,
-                              const char *group,
-                              const char *key,
-                              gint *value);
-
-#endif /* PCF_FILE_H */
-
-- 
1.7.0.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]