mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-06 05:50:28 +01:00
ifupdown: split parsers into convenience library for easier testcase creation
This commit is contained in:
parent
d39fda7722
commit
e386548132
4 changed files with 29 additions and 13 deletions
|
|
@ -5,15 +5,30 @@ INCLUDES = \
|
|||
-I$(top_srcdir)/libnm-glib \
|
||||
-I$(top_srcdir)/libnm-util
|
||||
|
||||
noinst_LTLIBRARIES = libifupdown-io.la
|
||||
|
||||
libifupdown_io_la_SOURCES = \
|
||||
interface_parser.c \
|
||||
interface_parser.h \
|
||||
parser.c \
|
||||
parser.h
|
||||
|
||||
libifupdown_io_la_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS) \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DSYSCONFDIR=\"$(sysconfdir)\"
|
||||
|
||||
libifupdown_io_la_LIBADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(GMODULE_LIBS)
|
||||
|
||||
pkglib_LTLIBRARIES = libnm-settings-plugin-ifupdown.la
|
||||
|
||||
libnm_settings_plugin_ifupdown_la_SOURCES = \
|
||||
interface_parser.c \
|
||||
interface_parser.h \
|
||||
nm-ifupdown-connection.c \
|
||||
nm-ifupdown-connection.h \
|
||||
parser.c \
|
||||
parser.h \
|
||||
plugin.c \
|
||||
plugin.h
|
||||
|
||||
|
|
@ -28,6 +43,7 @@ libnm_settings_plugin_ifupdown_la_CPPFLAGS = \
|
|||
libnm_settings_plugin_ifupdown_la_LDFLAGS = -module -avoid-version
|
||||
libnm_settings_plugin_ifupdown_la_LIBADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
libifupdown-io.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(GMODULE_LIBS) \
|
||||
$(GUDEV_LIBS)
|
||||
|
|
|
|||
|
|
@ -75,19 +75,19 @@ void add_data(const char *key,const char *data)
|
|||
|
||||
#define SPACE_OR_TAB(string,ret) {ret = strchr(string,' ');ret=(ret == NULL?strchr(string,'\t'):ret);}
|
||||
|
||||
void ifparser_init(void)
|
||||
void ifparser_init (const char *eni_file)
|
||||
{
|
||||
FILE *inp = fopen(ENI_INTERFACES_FILE, "r");
|
||||
FILE *inp = fopen (eni_file, "r");
|
||||
int ret = 0;
|
||||
char *line;
|
||||
char *space;
|
||||
char rline[255];
|
||||
|
||||
if (inp == NULL)
|
||||
{
|
||||
nm_warning ("Error: Can't open %s\n", ENI_INTERFACES_FILE);
|
||||
if (inp == NULL) {
|
||||
nm_warning ("Error: Can't open %s\n", eni_file);
|
||||
return;
|
||||
}
|
||||
|
||||
first = last = NULL;
|
||||
while(1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#define ENI_INTERFACES_FILE "/etc/network/interfaces"
|
||||
|
||||
typedef struct _if_data
|
||||
{
|
||||
char *key;
|
||||
|
|
@ -43,7 +41,7 @@ typedef struct _if_block
|
|||
struct _if_block *next;
|
||||
} if_block;
|
||||
|
||||
void ifparser_init(void);
|
||||
void ifparser_init(const char *eni_file);
|
||||
void ifparser_destroy(void);
|
||||
|
||||
if_block *ifparser_getif(const char* iface);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@
|
|||
#define G_UDEV_API_IS_SUBJECT_TO_CHANGE
|
||||
#include <gudev/gudev.h>
|
||||
|
||||
#define ENI_INTERFACES_FILE "/etc/network/interfaces"
|
||||
|
||||
#define IFUPDOWN_PLUGIN_NAME "ifupdown"
|
||||
#define IFUPDOWN_PLUGIN_INFO "(C) 2008 Canonical Ltd. To report bugs please use the NetworkManager mailing list."
|
||||
#define IFUPDOWN_SYSTEM_HOSTNAME_FILE "/etc/hostname"
|
||||
|
|
@ -355,7 +357,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
|
|||
update_system_hostname (inotify_helper, NULL, NULL, config);
|
||||
|
||||
/* Read in all the interfaces */
|
||||
ifparser_init ();
|
||||
ifparser_init (ENI_INTERFACES_FILE);
|
||||
block = ifparser_getfirst ();
|
||||
while (block) {
|
||||
if(!strcmp ("auto", block->type) || !strcmp ("allow-hotplug", block->type))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue