summaryrefslogtreecommitdiff
path: root/src/backends
diff options
context:
space:
mode:
authorAntti Kaijanmäki <antti@kaijanmaki.net>2008-08-18 08:30:28 +0000
committerAntti Kaijanmäki <antti@kaijanmaki.net>2008-08-18 08:30:28 +0000
commit2c21a2fe6b0498585fba0beb003ac8aa6351803c (patch)
tree9544edfe2ed9a6c96eda933c35fb5110f1d666c6 /src/backends
parente04934d93efba622123809cc767488af673b2967 (diff)
downloadNetworkManager-mbca.tar.gz
keep up with trunkmbca
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/branches/mbca@3981 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'src/backends')
-rw-r--r--src/backends/Makefile.am28
-rw-r--r--src/backends/NetworkManagerArch.c75
-rw-r--r--src/backends/NetworkManagerDebian.c69
-rw-r--r--src/backends/NetworkManagerFrugalware.c72
-rw-r--r--src/backends/NetworkManagerGeneric.c185
-rw-r--r--src/backends/NetworkManagerGeneric.h36
-rw-r--r--src/backends/NetworkManagerGentoo.c70
-rw-r--r--src/backends/NetworkManagerMandriva.c70
-rw-r--r--src/backends/NetworkManagerPaldo.c68
-rw-r--r--src/backends/NetworkManagerRedHat.c69
-rw-r--r--src/backends/NetworkManagerSlackware.c72
-rw-r--r--src/backends/NetworkManagerSuSE.c221
-rw-r--r--src/backends/shvar.c399
-rw-r--r--src/backends/shvar.h103
14 files changed, 16 insertions, 1521 deletions
diff --git a/src/backends/Makefile.am b/src/backends/Makefile.am
index 10830c7bc4..14af1de535 100644
--- a/src/backends/Makefile.am
+++ b/src/backends/Makefile.am
@@ -7,54 +7,46 @@ INCLUDES = -I${top_srcdir} \
noinst_LTLIBRARIES = libnmbackend.la
-libnmbackend_la_SOURCES = NetworkManagerGeneric.c \
+libnmbackend_la_SOURCES = NetworkManagerGeneric.c \
NetworkManagerGeneric.h
libnmbackend_la_LIBADD =
if TARGET_REDHAT
-libnmbackend_la_SOURCES += NetworkManagerRedHat.c \
- shvar.c \
- shvar.h
+libnmbackend_la_SOURCES += NetworkManagerRedHat.c
endif
if TARGET_SUSE
-libnmbackend_la_SOURCES += NetworkManagerSuSE.c \
- shvar.c \
- shvar.h
+libnmbackend_la_SOURCES += NetworkManagerSuSE.c
endif
if TARGET_GENTOO
-libnmbackend_la_SOURCES += NetworkManagerGentoo.c \
- shvar.c \
- shvar.h
+libnmbackend_la_SOURCES += NetworkManagerGentoo.c
endif
if TARGET_DEBIAN
-libnmbackend_la_SOURCES += NetworkManagerDebian.c
+libnmbackend_la_SOURCES += NetworkManagerDebian.c
endif
if TARGET_SLACKWARE
-libnmbackend_la_SOURCES += NetworkManagerSlackware.c
+libnmbackend_la_SOURCES += NetworkManagerSlackware.c
endif
if TARGET_ARCH
-libnmbackend_la_SOURCES += NetworkManagerArch.c
+libnmbackend_la_SOURCES += NetworkManagerArch.c
endif
if TARGET_PALDO
-libnmbackend_la_SOURCES += NetworkManagerPaldo.c
+libnmbackend_la_SOURCES += NetworkManagerPaldo.c
endif
if TARGET_FRUGALWARE
-libnmbackend_la_SOURCES += NetworkManagerFrugalware.c
+libnmbackend_la_SOURCES += NetworkManagerFrugalware.c
libnmbackend_la_LIBADD += -lfwnetconfig -lfwutil
endif
if TARGET_MANDRIVA
-libnmbackend_la_SOURCES += NetworkManagerMandriva.c \
- shvar.c \
- shvar.h
+libnmbackend_la_SOURCES += NetworkManagerMandriva.c
endif
libnmbackend_la_LIBADD += $(DBUS_LIBS) $(GTHREAD_LIBS)
diff --git a/src/backends/NetworkManagerArch.c b/src/backends/NetworkManagerArch.c
index c7dc1bfd37..3ed5677e87 100644
--- a/src/backends/NetworkManagerArch.c
+++ b/src/backends/NetworkManagerArch.c
@@ -36,31 +36,12 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <signal.h>
-#include <arpa/inet.h>
-#include <glib/gprintf.h>
-#include <glib/gfileutils.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -70,22 +51,10 @@ void nm_system_init (void)
*/
void nm_system_enable_loopback (void)
{
- nm_system_device_set_up_down_with_iface ("lo", TRUE);
+ nm_generic_enable_loopback ();
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
- nm_spawn_process ("/usr/bin/killall -q dhclient");
-}
-
-
-/*
* nm_system_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -96,48 +65,6 @@ void nm_system_update_dns (void)
{
/* Check if the daemon was already running - do not start a new instance */
if (g_file_test("/var/run/daemons/nscd", G_FILE_TEST_EXISTS))
- {
nm_spawn_process ("/etc/rc.d/nscd restart");
- }
-}
-
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
}
diff --git a/src/backends/NetworkManagerDebian.c b/src/backends/NetworkManagerDebian.c
index ef6e501460..d4a518befb 100644
--- a/src/backends/NetworkManagerDebian.c
+++ b/src/backends/NetworkManagerDebian.c
@@ -28,28 +28,12 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -63,18 +47,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
- nm_spawn_process ("/usr/bin/killall -q dhclient");
-}
-
-
-/*
* nm_system_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -84,46 +56,5 @@ void nm_system_kill_all_dhcp_daemons (void)
void nm_system_update_dns (void)
{
nm_spawn_process ("/usr/sbin/invoke-rc.d nscd restart");
-
-}
-
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
}
diff --git a/src/backends/NetworkManagerFrugalware.c b/src/backends/NetworkManagerFrugalware.c
index 301985ddf4..492bf19399 100644
--- a/src/backends/NetworkManagerFrugalware.c
+++ b/src/backends/NetworkManagerFrugalware.c
@@ -24,29 +24,13 @@
*/
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerSystem.h"
-#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-// Provided by the frugalwareutils package on Frugalware
-#include <libfwnetconfig.h>
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
-}
+/* Provided by the frugalwareutils package on Frugalware */
+#include <libfwnetconfig.h>
/*
* nm_system_enable_loopback
@@ -61,18 +45,6 @@ void nm_system_enable_loopback (void)
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
- nm_spawn_process ("/usr/bin/killall -q dhclient");
-}
-
-
-/*
* nm_system_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -84,43 +56,3 @@ void nm_system_update_dns (void)
/* I'm not running nscd */
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerGeneric.c b/src/backends/NetworkManagerGeneric.c
index 1143c4387b..93b1e1262d 100644
--- a/src/backends/NetworkManagerGeneric.c
+++ b/src/backends/NetworkManagerGeneric.c
@@ -34,9 +34,8 @@
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
#include "nm-netlink.h"
+#include "nm-utils.h"
/* Because of a bug in libnl, rtnl.h should be included before route.h */
#include <netlink/route/rtnl.h>
@@ -45,18 +44,6 @@
#include <netlink/netlink.h>
/*
- * nm_generic_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_generic_init (void)
-{
- /* Kill any dhclients lying around */
- nm_system_kill_all_dhcp_daemons ();
-}
-
-/*
* nm_generic_enable_loopback
*
* Bring up the loopback interface
@@ -112,17 +99,6 @@ out:
}
/*
- * nm_generic_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_generic_kill_all_dhcp_daemons (void)
-{
-}
-
-
-/*
* nm_generic_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -133,162 +109,3 @@ void nm_generic_update_dns (void)
{
}
-/*
- * nm_generic_set_ip4_config_from_resolv_conf
- *
- * Add nameservers and search names from a resolv.conf format file.
- *
- */
-void nm_generic_set_ip4_config_from_resolv_conf (const char *filename, NMIP4Config *ip4_config)
-{
- char * contents = NULL;
- char ** split_contents = NULL;
- int i, len;
-
- g_return_if_fail (filename != NULL);
- g_return_if_fail (ip4_config != NULL);
-
- if (!g_file_get_contents (filename, &contents, NULL, NULL) || (contents == NULL))
- return;
-
- if (!(split_contents = g_strsplit (contents, "\n", 0)))
- goto out;
-
- len = g_strv_length (split_contents);
- for (i = 0; i < len; i++)
- {
- char *line = split_contents[i];
-
- /* Ignore comments */
- if (!line || (line[0] == ';') || (line[0] == '#'))
- continue;
-
- line = g_strstrip (line);
- if ((strncmp (line, "search", 6) == 0) && (strlen (line) > 6))
- {
- char *searches = g_strdup (line + 7);
- char **split_searches = NULL;
-
- if (!searches || !strlen (searches))
- continue;
-
- /* Allow space-separated search domains */
- if ((split_searches = g_strsplit (searches, " ", 0)))
- {
- int m, srch_len;
-
- srch_len = g_strv_length (split_searches);
- for (m = 0; m < srch_len; m++)
- {
- if (split_searches[m])
- nm_ip4_config_add_domain (ip4_config, split_searches[m]);
- }
- g_strfreev (split_searches);
- }
- else
- {
- /* Only 1 item, add the whole line */
- nm_ip4_config_add_domain (ip4_config, searches);
- }
-
- g_free (searches);
- }
- else if ((strncmp (line, "nameserver", 10) == 0) && (strlen (line) > 10))
- {
- guint32 addr = (guint32) (inet_addr (line + 11));
-
- if (addr != (guint32) -1)
- nm_ip4_config_add_nameserver (ip4_config, addr);
- }
- }
-
- g_strfreev (split_contents);
-
-out:
- g_free (contents);
-}
-
-
-/*
- * nm_generic_device_get_system_config
- *
- * Retrieve any relevant configuration info for a particular device
- * from the system network configuration information. Clear out existing
- * info before setting stuff too.
- *
- */
-void* nm_generic_device_get_system_config (NMDevice *dev)
-{
- return NULL;
-}
-
-/*
- * nm_generic_device_free_system_config
- *
- * Free stored system config data
- *
- */
-void nm_generic_device_free_system_config (NMDevice *dev, void *system_config_data)
-{
- return;
-}
-
-
-/*
- * nm_generic_device_get_disabled
- *
- * Return whether the distro-specific system config tells us to use
- * dhcp for this device.
- *
- */
-gboolean nm_generic_device_get_disabled (NMDevice *dev)
-{
- return FALSE;
-}
-
-
-NMIP4Config *nm_generic_device_new_ip4_system_config (NMDevice *dev)
-{
- return NULL;
-}
-
-/*
- * nm_generic_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_generic_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_generic_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_generic_shutdown_nis (void)
-{
-}
-
-/*
- * nm_generic_set_hostname
- *
- * set the hostname
- *
- */
-void nm_generic_set_hostname (NMIP4Config *config)
-{
-}
-
-/*
- * nm_generic_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_generic_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerGeneric.h b/src/backends/NetworkManagerGeneric.h
index 420bc25a4e..0a0a88a215 100644
--- a/src/backends/NetworkManagerGeneric.h
+++ b/src/backends/NetworkManagerGeneric.h
@@ -24,39 +24,7 @@
#ifndef NETWORK_MANAGER_GENERIC_H
#define NETWORK_MANAGER_GENERIC_H
-#include <glib.h>
-#include "nm-device.h"
-#include "nm-ip4-config.h"
-#include "nm-named-manager.h"
-
-/* Prototypes for system/distribution dependent functions,
- * implemented in the backend files in backends/ directory
- */
-
-void nm_generic_init (void);
-
-void nm_generic_enable_loopback (void);
-void nm_generic_kill_all_dhcp_daemons (void);
-void nm_generic_update_dns (void);
-
-void nm_generic_set_ip4_config_from_resolv_conf (const char *filename, NMIP4Config *ip4_config);
-void * nm_generic_device_get_system_config (NMDevice *dev);
-void nm_generic_device_free_system_config (NMDevice *dev, void *system_config_data);
-NMIP4Config * nm_generic_device_new_ip4_system_config (NMDevice *dev);
-
-gboolean nm_generic_device_get_disabled (NMDevice *dev);
-
-gboolean nm_generic_device_set_from_ip4_config (NMDevice *dev);
-gboolean nm_generic_vpn_device_set_from_ip4_config (NMNamedManager *named, NMDevice *active_device, const char *iface, NMIP4Config *config, char **routes, int num_routes);
-gboolean nm_generic_vpn_device_unset_from_ip4_config (NMNamedManager *named, NMDevice *active_device, const char *iface, NMIP4Config *config);
-
-gboolean nm_generic_device_set_up_down (NMDevice *dev, gboolean up);
-gboolean nm_generic_device_set_up_down_with_iface (NMDevice *dev, const char *iface, gboolean up);
-
-void nm_generic_set_hostname (NMIP4Config *config);
-void nm_generic_activate_nis (NMIP4Config *config);
-void nm_generic_shutdown_nis (void);
-
-gboolean nm_generic_should_modify_resolv_conf (void);
+void nm_generic_enable_loopback (void);
+void nm_generic_update_dns (void);
#endif
diff --git a/src/backends/NetworkManagerGentoo.c b/src/backends/NetworkManagerGentoo.c
index ee7e0dbddc..7fa12078a1 100644
--- a/src/backends/NetworkManagerGentoo.c
+++ b/src/backends/NetworkManagerGentoo.c
@@ -28,29 +28,12 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
#include <string.h>
#include <stdlib.h>
-#include <arpa/inet.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-#include "shvar.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -66,18 +49,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
- /* TODO */
- /* Tell dhcdbd to kill its dhclient instance */
-}
-
-/*
* nm_system_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -94,44 +65,3 @@ void nm_system_update_dns (void)
#endif
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
-
diff --git a/src/backends/NetworkManagerMandriva.c b/src/backends/NetworkManagerMandriva.c
index f41c4bdc46..527a25d896 100644
--- a/src/backends/NetworkManagerMandriva.c
+++ b/src/backends/NetworkManagerMandriva.c
@@ -26,30 +26,12 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-#include "shvar.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
-
/*
* nm_system_enable_loopback
@@ -63,17 +45,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
-}
-
-
-/*
* nm_system_update_dns
*
* Invalidate the nscd host cache, if it exists, since
@@ -88,44 +59,3 @@ void nm_system_update_dns (void)
}
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerPaldo.c b/src/backends/NetworkManagerPaldo.c
index 017d0cbb94..0147a3b0e4 100644
--- a/src/backends/NetworkManagerPaldo.c
+++ b/src/backends/NetworkManagerPaldo.c
@@ -27,31 +27,15 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <arpa/inet.h>
-#include <glib/gkeyfile.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
#include "nm-utils.h"
/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
-
-/*
* nm_system_enable_loopback
*
* Bring up the loopback interface
@@ -63,17 +47,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
-}
-
-
-/*
* nm_system_update_dns
*
* Invalidate the nscd host cache, if it exists, since
@@ -86,44 +59,3 @@ void nm_system_update_dns (void)
nm_spawn_process ("/usr/sbin/nscd -i hosts");
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerRedHat.c b/src/backends/NetworkManagerRedHat.c
index 284ef40e4e..1e3f7e9652 100644
--- a/src/backends/NetworkManagerRedHat.c
+++ b/src/backends/NetworkManagerRedHat.c
@@ -24,29 +24,12 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-#include "shvar.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -60,17 +43,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
-}
-
-
-/*
* nm_system_update_dns
*
* Invalidate the nscd host cache, if it exists, since
@@ -85,44 +57,3 @@ void nm_system_update_dns (void)
}
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerSlackware.c b/src/backends/NetworkManagerSlackware.c
index 91fac1c766..8d7c5bf294 100644
--- a/src/backends/NetworkManagerSlackware.c
+++ b/src/backends/NetworkManagerSlackware.c
@@ -25,31 +25,11 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
-#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-
-/*
- * Mostly a mix of the Gentoo and RedHat Backends
- */
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -64,18 +44,6 @@ void nm_system_enable_loopback (void)
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
- nm_spawn_process ("/bin/killall -q dhcpcd");
-}
-
-
-/*
* nm_system_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -87,43 +55,3 @@ void nm_system_update_dns (void)
/* I'm not running nscd */
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerSuSE.c b/src/backends/NetworkManagerSuSE.c
index 8578c7b4cb..a0cd1cb105 100644
--- a/src/backends/NetworkManagerSuSE.c
+++ b/src/backends/NetworkManagerSuSE.c
@@ -28,34 +28,13 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/stat.h>
-#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <errno.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "NetworkManagerPolicy.h"
#include "nm-utils.h"
-#include "shvar.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -69,17 +48,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
-}
-
-
-/*
* nm_system_update_dns
*
* Invalidate the nscd host cache, if it exists, since
@@ -92,192 +60,3 @@ void nm_system_update_dns (void)
nm_spawn_process ("/usr/sbin/nscd -i hosts");
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
- shvarFile *file;
- const char *nis_domain;
- char *name, *buf;
- struct in_addr temp_addr;
- int i;
- FILE *ypconf = NULL;
- char addr_buf[INET_ADDRSTRLEN+1];
-
- memset (&addr_buf, '\0', sizeof (addr_buf));
-
- g_return_if_fail (config != NULL);
-
- nis_domain = nm_ip4_config_get_nis_domain(config);
-
- name = g_strdup_printf (SYSCONFDIR"/sysconfig/network/dhcp");
- file = svNewFile (name);
- if (!file)
- goto out_gfree;
-
- buf = svGetValue (file, "DHCLIENT_SET_DOMAINNAME");
- if (!buf)
- goto out_close;
-
- if ((!strcmp (buf, "yes")) && nis_domain && (setdomainname (nis_domain, strlen (nis_domain)) < 0))
- nm_warning ("Could not set nis domain name.");
- free (buf);
-
- buf = svGetValue (file, "DHCLIENT_MODIFY_NIS_CONF");
- if (!buf)
- goto out_close;
-
- if (!strcmp (buf, "yes")) {
- int num_nis_servers;
-
- num_nis_servers = nm_ip4_config_get_num_nis_servers(config);
- if (num_nis_servers > 0)
- {
- struct stat sb;
-
- /* write out yp.conf and restart the daemon */
-
- ypconf = fopen ("/etc/yp.conf", "w");
-
- if (ypconf)
- {
- fprintf (ypconf, "# generated by NetworkManager, do not edit!\n\n");
- for (i = 0; i < num_nis_servers; i++) {
- temp_addr.s_addr = nm_ip4_config_get_nis_server (config, i);
-
- if (!inet_ntop (AF_INET, &temp_addr, addr_buf, INET_ADDRSTRLEN))
- nm_warning ("%s: error converting IP4 address 0x%X",
- __func__, ntohl (temp_addr.s_addr));
- else
- fprintf (ypconf, "domain %s server %s\n", nis_domain, addr_buf);
- }
- fprintf (ypconf, "\n");
- fclose (ypconf);
- } else
- nm_warning ("Could not commit NIS changes to /etc/yp.conf.");
-
- if (stat ("/usr/sbin/rcautofs", &sb) != -1)
- {
- nm_info ("Restarting autofs.");
- nm_spawn_process ("/usr/sbin/rcautofs reload");
- }
- }
- }
- free (buf);
-
-out_close:
- svCloseFile (file);
-out_gfree:
- g_free (name);
-}
-
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
- char *filename, *h_name = NULL, *buf;
- shvarFile *file;
-
- g_return_if_fail (config != NULL);
-
- filename = g_strdup_printf (SYSCONFDIR"/sysconfig/network/dhcp");
- file = svNewFile (filename);
- if (!file)
- goto out_gfree;
-
- buf = svGetValue (file, "DHCLIENT_SET_HOSTNAME");
- if (!buf)
- goto out_close;
-
- if (!strcmp (buf, "yes"))
- {
- const char *hostname;
-
- hostname = nm_ip4_config_get_hostname (config);
- if (!hostname)
- {
- struct in_addr temp_addr;
- struct hostent *host;
- const NMSettingIP4Address *ip_address;
-
- /* try to get hostname via dns */
- ip_address = nm_ip4_config_get_address (config, 0);
- temp_addr.s_addr = ip_address->address;
- host = gethostbyaddr ((char *) &temp_addr, sizeof (temp_addr), AF_INET);
- if (host)
- {
- h_name = g_strdup (host->h_name);
- hostname = strtok (h_name, ".");
- }
- else
- nm_warning ("nm_system_set_hostname(): gethostbyaddr failed, h_errno = %d", h_errno);
- }
-
- if (hostname)
- {
- nm_info ("Setting hostname to '%s'", hostname);
- if (sethostname (hostname, strlen (hostname)) < 0)
- nm_warning ("Could not set hostname.");
- }
- }
-
- g_free (h_name);
- free (buf);
-out_close:
- svCloseFile (file);
-out_gfree:
- g_free (filename);
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- char *name, *buf;
- shvarFile *file;
- gboolean ret = TRUE;
-
- name = g_strdup_printf (SYSCONFDIR"/sysconfig/network/dhcp");
- file = svNewFile (name);
- if (!file)
- goto out_gfree;
-
- buf = svGetValue (file, "DHCLIENT_MODIFY_RESOLV_CONF");
- if (!buf)
- goto out_close;
-
- if (strcmp (buf, "no") == 0)
- ret = FALSE;
-
- free (buf);
-out_close:
- svCloseFile (file);
-out_gfree:
- g_free (name);
-
- return ret;
-}
-
diff --git a/src/backends/shvar.c b/src/backends/shvar.c
deleted file mode 100644
index 67b3019d48..0000000000
--- a/src/backends/shvar.c
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * shvar.c
- *
- * Implementation of non-destructively reading/writing files containing
- * only shell variable declarations and full-line comments.
- *
- * Includes explicit inheritance mechanism intended for use with
- * Red Hat Linux ifcfg-* files. There is no protection against
- * inheritance loops; they will generally cause stack overflows.
- * Furthermore, they are only intended for one level of inheritance;
- * the value setting algorithm assumes this.
- *
- * Copyright 1999,2000 Red Hat, Inc.
- *
- * This 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.
- *
- */
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "shvar.h"
-
-/* Open the file <name>, returning a shvarFile on success and NULL on failure.
- Add a wrinkle to let the caller specify whether or not to create the file
- (actually, return a structure anyway) if it doesn't exist. */
-static shvarFile *
-svOpenFile(const char *name, gboolean create)
-{
- shvarFile *s = NULL;
- int closefd = 0;
-
- s = g_malloc0(sizeof(shvarFile));
-
-#if 1 /* NetworkManager local change */
- s->fd = open(name, O_RDONLY); /* NOT O_CREAT */
- if (s->fd != -1) closefd = 1;
-#else
- s->fd = open(name, O_RDWR); /* NOT O_CREAT */
- if (s->fd == -1) {
- /* try read-only */
- s->fd = open(name, O_RDONLY); /* NOT O_CREAT */
- if (s->fd != -1) closefd = 1;
- }
-#endif
- s->fileName = g_strdup(name);
-
- if (s->fd != -1) {
- struct stat buf;
- char *p, *q;
-
- if (fstat(s->fd, &buf) < 0) goto bail;
- s->arena = g_malloc0(buf.st_size + 1);
-
- if (read(s->fd, s->arena, buf.st_size) < 0) goto bail;
-
- /* we'd use g_strsplit() here, but we want a list, not an array */
- for(p = s->arena; (q = strchr(p, '\n')) != NULL; p = q + 1) {
- s->lineList = g_list_append(s->lineList, g_strndup(p, q - p));
- }
-
- /* closefd is set if we opened the file read-only, so go ahead and
- close it, because we can't write to it anyway */
- if (closefd) {
- close(s->fd);
- s->fd = -1;
- }
-
- return s;
- }
-
- if (create) {
- return s;
- }
-
-bail:
- if (s->fd != -1) close(s->fd);
- if (s->arena) g_free (s->arena);
- if (s->fileName) g_free (s->fileName);
- g_free (s);
- return NULL;
-}
-
-/* Open the file <name>, return shvarFile on success, NULL on failure */
-shvarFile *
-svNewFile(const char *name)
-{
- return svOpenFile(name, FALSE);
-}
-
-/* Create a new file structure, returning actual data if the file exists,
- * and a suitable starting point if it doesn't. */
-shvarFile *
-svCreateFile(const char *name)
-{
- return svOpenFile(name, TRUE);
-}
-
-/* remove escaped characters in place */
-static void
-unescape(char *s) {
- int len, i;
-
- len = strlen(s);
- if ((s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) {
- i = len - 2;
- memmove(s, s+1, i);
- s[i+1] = '\0';
- len = i;
- }
- for (i = 0; i < len; i++) {
- if (s[i] == '\\') {
- memmove(s+i, s+i+1, len-(i+1));
- len--;
- }
- s[len] = '\0';
- }
-}
-
-
-/* create a new string with all necessary characters escaped.
- * caller must free returned string
- */
-static const char escapees[] = "\"'\\$~`"; /* must be escaped */
-static const char spaces[] = " \t|&;()<>"; /* only require "" */
-static char *
-escape(const char *s) {
- char *new;
- int i, j, mangle = 0, space = 0;
- int newlen, slen;
- static int esclen, splen;
-
- if (!esclen) esclen = strlen(escapees);
- if (!splen) splen = strlen(spaces);
- slen = strlen(s);
-
- for (i = 0; i < slen; i++) {
- if (strchr(escapees, s[i])) mangle++;
- if (strchr(spaces, s[i])) space++;
- }
- if (!mangle && !space) return strdup(s);
-
- newlen = slen + mangle + 3; /* 3 is extra ""\0 */
- new = g_malloc0(newlen);
- if (!new) return NULL;
-
- j = 0;
- new[j++] = '"';
- for (i = 0; i < slen; i++) {
- if (strchr(escapees, s[i])) {
- new[j++] = '\\';
- }
- new[j++] = s[i];
- }
- new[j++] = '"';
- g_assert(j == slen + mangle + 2); /* j is the index of the '\0' */
-
- return new;
-}
-
-/* Get the value associated with the key, and leave the current pointer
- * pointing at the line containing the value. The char* returned MUST
- * be freed by the caller.
- */
-char *
-svGetValue(shvarFile *s, const char *key)
-{
- char *value = NULL;
- char *line;
- char *keyString;
- int len;
-
- g_assert(s);
- g_assert(key);
-
- keyString = g_malloc0(strlen(key) + 2);
- strcpy(keyString, key);
- keyString[strlen(key)] = '=';
- len = strlen(keyString);
-
- for (s->current = s->lineList; s->current; s->current = s->current->next) {
- line = s->current->data;
- if (!strncmp(keyString, line, len)) {
- value = g_strdup(line + len);
- unescape(value);
- break;
- }
- }
- g_free(keyString);
-
- if (value) {
- if (value[0]) {
- return value;
- } else {
- g_free(value);
- return NULL;
- }
- }
- if (s->parent) value = svGetValue(s->parent, key);
- return value;
-}
-
-/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true")
- * return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false")
- * return <default> otherwise
- */
-int
-svTrueValue(shvarFile *s, const char *key, int def)
-{
- char *tmp;
- int returnValue = def;
-
- tmp = svGetValue(s, key);
- if (!tmp) return returnValue;
-
- if ( (!strcasecmp("yes", tmp)) ||
- (!strcasecmp("true", tmp)) ||
- (!strcasecmp("t", tmp)) ||
- (!strcasecmp("y", tmp)) ) returnValue = 1;
- else
- if ( (!strcasecmp("no", tmp)) ||
- (!strcasecmp("false", tmp)) ||
- (!strcasecmp("f", tmp)) ||
- (!strcasecmp("n", tmp)) ) returnValue = 0;
-
- g_free (tmp);
- return returnValue;
-}
-
-
-/* Set the variable <key> equal to the value <value>.
- * If <key> does not exist, and the <current> pointer is set, append
- * the key=value pair after that line. Otherwise, prepend the pair
- * to the top of the file. Here's the algorithm, as the C code
- * seems to be rather dense:
- *
- * if (value == NULL), then:
- * if val2 (parent): change line to key= or append line key=
- * if val1 (this) : delete line
- * else noop
- * else use this table:
- * val2
- * NULL value other
- * v NULL append line noop append line
- * a
- * l value noop noop noop
- * 1
- * other change line delete line change line
- *
- * No changes are ever made to the parent config file, only to the
- * specific file passed on the command line.
- *
- */
-void
-svSetValue(shvarFile *s, const char *key, const char *value)
-{
- char *newval = NULL, *val1 = NULL, *val2 = NULL;
- char *keyValue;
-
- g_assert(s);
- g_assert(key);
- /* value may be NULL */
-
- if (value) newval = escape(value);
- keyValue = g_strdup_printf("%s=%s", key, newval ? newval : "");
-
- val1 = svGetValue(s, key);
- if (val1 && newval && !strcmp(val1, newval)) goto bail;
- if (s->parent) val2 = svGetValue(s->parent, key);
-
- if (!newval || !newval[0]) {
- /* delete value somehow */
- if (val2) {
- /* change/append line to get key= */
- if (s->current) s->current->data = keyValue;
- else s->lineList = g_list_append(s->lineList, keyValue);
- s->freeList = g_list_append(s->freeList, keyValue);
- s->modified = 1;
- } else if (val1) {
- /* delete line */
- s->lineList = g_list_remove_link(s->lineList, s->current);
- g_list_free_1(s->current);
- s->modified = 1;
- goto bail; /* do not need keyValue */
- }
- goto end;
- }
-
- if (!val1) {
- if (val2 && !strcmp(val2, newval)) goto end;
- /* append line */
- s->lineList = g_list_append(s->lineList, keyValue);
- s->freeList = g_list_append(s->freeList, keyValue);
- s->modified = 1;
- goto end;
- }
-
- /* deal with a whole line of noops */
- if (val1 && !strcmp(val1, newval)) goto end;
-
- /* At this point, val1 && val1 != value */
- if (val2 && !strcmp(val2, newval)) {
- /* delete line */
- s->lineList = g_list_remove_link(s->lineList, s->current);
- g_list_free_1(s->current);
- s->modified = 1;
- goto bail; /* do not need keyValue */
- } else {
- /* change line */
- if (s->current) s->current->data = keyValue;
- else s->lineList = g_list_append(s->lineList, keyValue);
- s->freeList = g_list_append(s->freeList, keyValue);
- s->modified = 1;
- }
-
-end:
- if (newval) free(newval);
- if (val1) free(val1);
- if (val2) free(val2);
- return;
-
-bail:
- if (keyValue) free (keyValue);
- goto end;
-}
-
-/* Write the current contents iff modified. Returns -1 on error
- * and 0 on success. Do not write if no values have been modified.
- * The mode argument is only used if creating the file, not if
- * re-writing an existing file, and is passed unchanged to the
- * open() syscall.
- */
-int
-svWriteFile(shvarFile *s, int mode)
-{
- FILE *f;
- int tmpfd;
-
- if (s->modified) {
- if (s->fd == -1)
- s->fd = open(s->fileName, O_WRONLY|O_CREAT, mode);
- if (s->fd == -1)
- return -1;
- if (ftruncate(s->fd, 0) < 0)
- return -1;
-
- tmpfd = dup(s->fd);
- f = fdopen(tmpfd, "w");
- fseek(f, 0, SEEK_SET);
- for (s->current = s->lineList; s->current; s->current = s->current->next) {
- char *line = s->current->data;
- fprintf(f, "%s\n", line);
- }
- fclose(f);
- }
-
- return 0;
-}
-
-
-/* Close the file descriptor (if open) and delete the shvarFile.
- * Returns -1 on error and 0 on success.
- */
-int
-svCloseFile(shvarFile *s)
-{
-
- g_assert(s);
-
- if (s->fd != -1) close(s->fd);
-
- g_free(s->arena);
- for (s->current = s->freeList; s->current; s->current = s->current->next) {
- g_free(s->current->data);
- }
- g_free(s->fileName);
- g_list_free(s->freeList);
- g_list_foreach (s->lineList, (GFunc) g_free, NULL);
- g_list_free(s->lineList); /* implicitly frees s->current */
- g_free(s);
- return 0;
-}
diff --git a/src/backends/shvar.h b/src/backends/shvar.h
deleted file mode 100644
index 00e1a8e59f..0000000000
--- a/src/backends/shvar.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * shvar.h
- *
- * Interface for non-destructively reading/writing files containing
- * only shell variable declarations and full-line comments.
- *
- * Includes explicit inheritance mechanism intended for use with
- * Red Hat Linux ifcfg-* files. There is no protection against
- * inheritance loops; they will generally cause stack overflows.
- * Furthermore, they are only intended for one level of inheritance;
- * the value setting algorithm assumes this.
- *
- * Copyright 1999 Red Hat, Inc.
- *
- * This 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.
- *
- */
-#ifndef _SHVAR_H
-#define _SHVAR_H
-
-#include <glib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-typedef struct _shvarFile shvarFile;
-struct _shvarFile {
- char *fileName; /* read-only */
- int fd; /* read-only */
- char *arena; /* ignore */
- GList *lineList; /* read-only */
- GList *freeList; /* ignore */
- GList *current; /* set implicitly or explicitly,
- points to element of lineList */
- shvarFile *parent; /* set explicitly */
- int modified; /* ignore */
-};
-
-
-/* Create the file <name>, return shvarFile on success, NULL on failure */
-shvarFile *
-svCreateFile(const char *name);
-
-/* Open the file <name>, return shvarFile on success, NULL on failure */
-shvarFile *
-svNewFile(const char *name);
-
-/* Get the value associated with the key, and leave the current pointer
- * pointing at the line containing the value. The char* returned MUST
- * be freed by the caller.
- */
-char *
-svGetValue(shvarFile *s, const char *key);
-
-/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true")
- * return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false")
- * return <def> otherwise
- */
-int
-svTrueValue(shvarFile *s, const char *key, int def);
-
-/* Set the variable <key> equal to the value <value>.
- * If <key> does not exist, and the <current> pointer is set, append
- * the key=value pair after that line. Otherwise, prepend the pair
- * to the top of the file.
- */
-void
-svSetValue(shvarFile *s, const char *key, const char *value);
-
-
-/* Write the current contents iff modified. Returns -1 on error
- * and 0 on success. Do not write if no values have been modified.
- * The mode argument is only used if creating the file, not if
- * re-writing an existing file, and is passed unchanged to the
- * open() syscall.
- */
-int
-svWriteFile(shvarFile *s, int mode);
-
-/* Close the file descriptor (if open) and delete the shvarFile.
- * Returns -1 on error and 0 on success.
- */
-int
-svCloseFile(shvarFile *s);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* ! _SHVAR_H */