[netcf-devel] [PATCH 1/3] Move all general functions to dutil.c

Jonas Eriksson jonas.j.eriksson at ericsson.com
Fri Jul 17 15:32:42 UTC 2009


All functions that can be moved from drv_initscript.c without needing any large
code changes are moved to dutil.{c/h}.
---
 src/Makefile.am       |    2 +-
 src/drv_initscripts.c |  220 +---------------------------------------
 src/dutil.c           |  269 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/dutil.h           |   87 ++++++++++++++++
 4 files changed, 363 insertions(+), 215 deletions(-)
 create mode 100644 src/dutil.c
 create mode 100644 src/dutil.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 8c84454..58f5d7c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,7 +17,7 @@ EXTRA_DIST = netcf_public.syms \
 	netcf_private.syms
 
 if NETCF_DRIVER_INITSCRIPTS
-DRIVER_SOURCES = drv_initscripts.c
+DRIVER_SOURCES = drv_initscripts.c dutil.c
 endif
 
 BUILT_SOURCES = datadir.h netcf.syms
diff --git a/src/drv_initscripts.c b/src/drv_initscripts.c
index 66d668f..d51ac97 100644
--- a/src/drv_initscripts.c
+++ b/src/drv_initscripts.c
@@ -31,13 +31,10 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
 #include "safe-alloc.h"
 #include "ref.h"
 #include "list.h"
+#include "dutil.h"
 
 #include <libxml/parser.h>
 #include <libxml/relaxng.h>
@@ -86,15 +83,6 @@ static const char *const lokkit_custom_rules =
 
 static const char *const prog_rc_d_iptables = "/etc/init.d/iptables";
 
-struct driver {
-    struct augeas     *augeas;
-    xsltStylesheetPtr  put;
-    xsltStylesheetPtr  get;
-    xmlRelaxNGPtr      rng;
-    int                ioctl_fd;
-    unsigned int       load_augeas : 1;
-};
-
 /* Entries in a ifcfg file that tell us that the interface
  * is not a toplevel interface
  */
@@ -102,19 +90,6 @@ static const char *const subif_paths[] = {
     "MASTER", "BRIDGE"
 };
 
-/* Like asprintf, but set *STRP to NULL on error */
-static int xasprintf(char **strp, const char *format, ...) {
-  va_list args;
-  int result;
-
-  va_start (args, format);
-  result = vasprintf (strp, format, args);
-  va_end (args);
-  if (result < 0)
-      *strp = NULL;
-  return result;
-}
-
 /* Get the Augeas instance; if we already initialized it, just return
  * it. Otherwise, create a new one and return that.
  */
@@ -220,14 +195,6 @@ static int aug_submatch(struct netcf *ncf, const char *p1,
     return -1;
 }
 
-static void free_matches(int nint, char ***intf) {
-    if (*intf != NULL) {
-        for (int i=0; i < nint; i++)
-            FREE((*intf)[i]);
-        FREE(*intf);
-    }
-}
-
 static int is_slave(struct netcf *ncf, const char *intf) {
     for (int s = 0; s < ARRAY_CARDINALITY(subif_paths); s++) {
         int r;
@@ -238,18 +205,6 @@ static int is_slave(struct netcf *ncf, const char *intf) {
     return 0;
 }
 
-static int is_active(struct netcf *ncf, const char *intf) {
-    struct ifreq ifr;
-
-    MEMZERO(&ifr, 1);
-    strncpy(ifr.ifr_name, intf, sizeof(ifr.ifr_name));
-    ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
-    if (ioctl(ncf->driver->ioctl_fd, SIOCGIFFLAGS, &ifr))  {
-        return 0;
-    }
-    return ((ifr.ifr_flags & IFF_UP) == IFF_UP);
-}
-
 static int list_interfaces(struct netcf *ncf, char ***intf) {
     int nint = 0, result = 0;
     struct augeas *aug = NULL;
@@ -393,92 +348,6 @@ static void bridge_physdevs(struct netcf *ncf) {
     return;
 }
 
-static xsltStylesheetPtr parse_stylesheet(struct netcf *ncf,
-                                          const char *fname) {
-    xsltStylesheetPtr result = NULL;
-    char *path = NULL;
-    int r;
-
-    r = xasprintf(&path, "%s/xml/%s", ncf->data_dir, fname);
-    ERR_COND_BAIL(r < 0, ncf, ENOMEM);
-
-    // FIXME: Error checking ??
-    result = xsltParseStylesheetFile(BAD_CAST path);
- error:
-    free(path);
-    return result;
-}
-
-/* Callback for reporting RelaxNG errors */
-static void rng_error(void *ctx, const char *format, ...) {
-    struct netcf *ncf = ctx;
-    va_list ap;
-
-    va_start(ap, format);
-    vreport_error(ncf, NETCF_EXMLINVALID, format, ap);
-    va_end(ap);
-}
-
-static xmlRelaxNGPtr rng_parse(struct netcf *ncf, const char *fname) {
-    char *path = NULL;
-    xmlRelaxNGPtr result = NULL;
-    xmlRelaxNGParserCtxtPtr ctxt = NULL;
-    int r;
-
-    r = xasprintf(&path, "%s/xml/%s", ncf->data_dir, fname);
-    ERR_COND_BAIL(r < 0, ncf, ENOMEM);
-
-    ctxt = xmlRelaxNGNewParserCtxt(path);
-    xmlRelaxNGSetParserErrors(ctxt, rng_error, rng_error, ncf);
-
-    result = xmlRelaxNGParse(ctxt);
-
- error:
-    xmlRelaxNGFreeParserCtxt(ctxt);
-    free(path);
-    return result;
-}
-
-static void rng_validate(struct netcf *ncf, xmlDocPtr doc) {
-	xmlRelaxNGValidCtxtPtr ctxt;
-	int r;
-
-	ctxt = xmlRelaxNGNewValidCtxt(ncf->driver->rng);
-	xmlRelaxNGSetValidErrors(ctxt, rng_error, rng_error, ncf);
-
-    r = xmlRelaxNGValidateDoc(ctxt, doc);
-    if (r != 0 && ncf->errcode == NETCF_NOERROR)
-        report_error(ncf, NETCF_EXMLINVALID,
-           "Interface definition fails to validate");
-
-	xmlRelaxNGFreeValidCtxt(ctxt);
-}
-
-static char *xml_prop(xmlNodePtr node, const char *name) {
-    return (char *) xmlGetProp(node, BAD_CAST name);
-}
-
-static int init_ioctl_fd(struct netcf *ncf) {
-
-    int ioctl_fd;
-    int flags;
-
-    ioctl_fd = socket(AF_INET, SOCK_STREAM, 0);
-    ERR_THROW(ioctl_fd < 0, ncf, EINTERNAL, "failed to open socket for interface ioctl");
-
-    flags = fcntl(ioctl_fd, F_GETFD);
-    ERR_THROW(flags < 0, ncf, EINTERNAL, "failed to get flags for ioctl socket");
-
-    flags = fcntl(ioctl_fd, F_SETFD, flags | FD_CLOEXEC);
-    ERR_THROW(flags < 0, ncf, EINTERNAL, "failed to set FD_CLOEXEC flag on ioctl socket");
-    return ioctl_fd;
-
-error:
-    if (ioctl_fd >= 0)
-        close(ioctl_fd);
-    return -1;
-}
-
 int drv_init(struct netcf *ncf) {
     int r;
 
@@ -732,51 +601,6 @@ static int aug_put_xml(struct netcf *ncf, xmlDocPtr xml) {
     return result;
 }
 
-/* Called from SAX on parsing errors in the XML. */
-static void
-catch_xml_error(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) {
-    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
-
-    if (ctxt != NULL) {
-        struct netcf *ncf = ctxt->_private;
-
-        if (ctxt->lastError.level == XML_ERR_FATAL &&
-            ctxt->lastError.message != NULL) {
-            report_error(ncf, NETCF_EXMLPARSER,
-                         "at line %d: %s",
-                         ctxt->lastError.line,
-                         ctxt->lastError.message);
-        }
-    }
-}
-
-static xmlDocPtr parse_xml(struct netcf *ncf, const char *xml_str) {
-    xmlParserCtxtPtr pctxt;
-    xmlDocPtr xml = NULL;
-
-    /* Set up a parser context so we can catch the details of XML errors. */
-    pctxt = xmlNewParserCtxt();
-    ERR_COND_BAIL(pctxt == NULL || pctxt->sax == NULL, ncf, ENOMEM);
-
-    pctxt->sax->error = catch_xml_error;
-    pctxt->_private = ncf;
-
-    xml = xmlCtxtReadDoc (pctxt, BAD_CAST xml_str, "netcf.xml", NULL,
-                          XML_PARSE_NOENT | XML_PARSE_NONET |
-                          XML_PARSE_NOWARNING);
-    ERR_THROW(xml == NULL, ncf, EXMLPARSER,
-              "failed to parse xml document");
-    ERR_THROW(xmlDocGetRootElement(xml) == NULL, ncf, EINTERNAL,
-              "missing root element");
-
-    xmlFreeParserCtxt(pctxt);
-    return xml;
-error:
-    xmlFreeParserCtxt (pctxt);
-    xmlFreeDoc (xml);
-    return NULL;
-}
-
 char *drv_xml_desc(struct netcf_if *nif) {
     char *path = NULL, *result = NULL;
     struct augeas *aug;
@@ -1188,47 +1012,14 @@ int drv_if_down(struct netcf_if *nif) {
  * Test interface
  */
 int drv_get_aug(struct netcf *ncf, const char *ncf_xml, char **aug_xml) {
-    xmlDocPtr ncf_doc = NULL, aug_doc = NULL;
-    int result = -1;
-
-    ncf_doc = parse_xml(ncf, ncf_xml);
-    ERR_BAIL(ncf);
-
-    rng_validate(ncf, ncf_doc);
-    ERR_BAIL(ncf);
-
-    // FIXME: Check for errors from ApplyStylesheet
-    aug_doc = xsltApplyStylesheet(ncf->driver->get, ncf_doc, NULL);
-
-    xmlDocDumpFormatMemory(aug_doc, (xmlChar **) aug_xml, NULL, 1);
-    ERR_COND_BAIL(*aug_xml == NULL, ncf, EXMLINVALID);
-    /* fallthrough intentional */
-    result = 0;
- error:
-    xmlFreeDoc(ncf_doc);
-    xmlFreeDoc(aug_doc);
-    return result;
+    /* Use utility implementation */
+    return _drv_get_aug(ncf, ncf_xml, aug_xml);
 }
 
 /* Transform the Augeas XML AUG_XML into interface XML NCF_XML */
 int drv_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml) {
-    xmlDocPtr ncf_doc = NULL, aug_doc = NULL;
-    int result = -1;
-
-    aug_doc = parse_xml(ncf, aug_xml);
-    ERR_BAIL(ncf);
-
-    // FIXME: Check for errors from ApplyStylesheet
-    ncf_doc = xsltApplyStylesheet(ncf->driver->put, aug_doc, NULL);
-
-    xmlDocDumpFormatMemory(ncf_doc, (xmlChar **) ncf_xml, NULL, 1);
-    ERR_COND_BAIL(*ncf_xml == NULL, ncf, EXMLINVALID);
-    /* fallthrough intentional */
-    result = 0;
- error:
-    xmlFreeDoc(ncf_doc);
-    xmlFreeDoc(aug_doc);
-    return result;
+    /* Use utility implementation */
+    return _drv_put_aug(ncf, aug_xml, ncf_xml);
 }
 
 /*
@@ -1239,3 +1030,4 @@ int drv_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml) {
  *  tab-width: 4
  * End:
  */
+/* vim: set ts=4 sw=4 et: */
diff --git a/src/dutil.c b/src/dutil.c
new file mode 100644
index 0000000..c15bfbc
--- /dev/null
+++ b/src/dutil.c
@@ -0,0 +1,269 @@
+/*
+ * dutil.c: Global utility functions for driver backends.
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter at redhat.com>
+ */
+
+#include <config.h>
+#include <internal.h>
+
+#include <augeas.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+
+#include "safe-alloc.h"
+#include "ref.h"
+#include "list.h"
+#include "netcf.h"
+#include "dutil.h"
+
+#include <libxml/parser.h>
+#include <libxml/relaxng.h>
+#include <libxml/tree.h>
+#include <libxslt/xslt.h>
+#include <libxslt/xsltInternals.h>
+#include <libxslt/transform.h>
+
+/* Like asprintf, but set *STRP to NULL on error */
+int xasprintf(char **strp, const char *format, ...) {
+  va_list args;
+  int result;
+
+  va_start (args, format);
+  result = vasprintf (strp, format, args);
+  va_end (args);
+  if (result < 0)
+      *strp = NULL;
+  return result;
+}
+
+void free_matches(int nint, char ***intf) {
+    if (*intf != NULL) {
+        for (int i=0; i < nint; i++)
+            FREE((*intf)[i]);
+        FREE(*intf);
+    }
+}
+
+xsltStylesheetPtr parse_stylesheet(struct netcf *ncf,
+                                          const char *fname) {
+    xsltStylesheetPtr result = NULL;
+    char *path = NULL;
+    int r;
+
+    r = xasprintf(&path, "%s/xml/%s", ncf->data_dir, fname);
+    ERR_COND_BAIL(r < 0, ncf, ENOMEM);
+
+    // FIXME: Error checking ??
+    result = xsltParseStylesheetFile(BAD_CAST path);
+ error:
+    free(path);
+    return result;
+}
+
+/* Callback for reporting RelaxNG errors */
+void rng_error(void *ctx, const char *format, ...) {
+    struct netcf *ncf = ctx;
+    va_list ap;
+
+    va_start(ap, format);
+    vreport_error(ncf, NETCF_EXMLINVALID, format, ap);
+    va_end(ap);
+}
+
+xmlRelaxNGPtr rng_parse(struct netcf *ncf, const char *fname) {
+    char *path = NULL;
+    xmlRelaxNGPtr result = NULL;
+    xmlRelaxNGParserCtxtPtr ctxt = NULL;
+    int r;
+
+    r = xasprintf(&path, "%s/xml/%s", ncf->data_dir, fname);
+    ERR_COND_BAIL(r < 0, ncf, ENOMEM);
+
+    ctxt = xmlRelaxNGNewParserCtxt(path);
+    xmlRelaxNGSetParserErrors(ctxt, rng_error, rng_error, ncf);
+
+    result = xmlRelaxNGParse(ctxt);
+
+ error:
+    xmlRelaxNGFreeParserCtxt(ctxt);
+    free(path);
+    return result;
+}
+
+void rng_validate(struct netcf *ncf, xmlDocPtr doc) {
+	xmlRelaxNGValidCtxtPtr ctxt;
+	int r;
+
+	ctxt = xmlRelaxNGNewValidCtxt(ncf->driver->rng);
+	xmlRelaxNGSetValidErrors(ctxt, rng_error, rng_error, ncf);
+
+    r = xmlRelaxNGValidateDoc(ctxt, doc);
+    if (r != 0 && ncf->errcode == NETCF_NOERROR)
+        report_error(ncf, NETCF_EXMLINVALID,
+           "Interface definition fails to validate");
+
+	xmlRelaxNGFreeValidCtxt(ctxt);
+}
+
+/* Called from SAX on parsing errors in the XML. */
+void catch_xml_error(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) {
+    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
+
+    if (ctxt != NULL) {
+        struct netcf *ncf = ctxt->_private;
+
+        if (ctxt->lastError.level == XML_ERR_FATAL &&
+            ctxt->lastError.message != NULL) {
+            report_error(ncf, NETCF_EXMLPARSER,
+                         "at line %d: %s",
+                         ctxt->lastError.line,
+                         ctxt->lastError.message);
+        }
+    }
+}
+
+xmlDocPtr parse_xml(struct netcf *ncf, const char *xml_str) {
+    xmlParserCtxtPtr pctxt;
+    xmlDocPtr xml = NULL;
+
+    /* Set up a parser context so we can catch the details of XML errors. */
+    pctxt = xmlNewParserCtxt();
+    ERR_COND_BAIL(pctxt == NULL || pctxt->sax == NULL, ncf, ENOMEM);
+
+    pctxt->sax->error = catch_xml_error;
+    pctxt->_private = ncf;
+
+    xml = xmlCtxtReadDoc (pctxt, BAD_CAST xml_str, "netcf.xml", NULL,
+                          XML_PARSE_NOENT | XML_PARSE_NONET |
+                          XML_PARSE_NOWARNING);
+    ERR_THROW(xml == NULL, ncf, EXMLPARSER,
+              "failed to parse xml document");
+    ERR_THROW(xmlDocGetRootElement(xml) == NULL, ncf, EINTERNAL,
+              "missing root element");
+
+    xmlFreeParserCtxt(pctxt);
+    return xml;
+error:
+    xmlFreeParserCtxt (pctxt);
+    xmlFreeDoc (xml);
+    return NULL;
+}
+
+char *xml_prop(xmlNodePtr node, const char *name) {
+    return (char *) xmlGetProp(node, BAD_CAST name);
+}
+
+int init_ioctl_fd(struct netcf *ncf) {
+    int ioctl_fd;
+    int flags;
+
+    ioctl_fd = socket(AF_INET, SOCK_STREAM, 0);
+    ERR_THROW(ioctl_fd < 0, ncf, EINTERNAL, "failed to open socket for interface ioctl");
+
+    flags = fcntl(ioctl_fd, F_GETFD);
+    ERR_THROW(flags < 0, ncf, EINTERNAL, "failed to get flags for ioctl socket");
+
+    flags = fcntl(ioctl_fd, F_SETFD, flags | FD_CLOEXEC);
+    ERR_THROW(flags < 0, ncf, EINTERNAL, "failed to set FD_CLOEXEC flag on ioctl socket");
+    return ioctl_fd;
+
+error:
+    if (ioctl_fd >= 0)
+        close(ioctl_fd);
+    return -1;
+}
+
+int is_active(struct netcf *ncf, const char *intf) {
+    struct ifreq ifr;
+
+    MEMZERO(&ifr, 1);
+    strncpy(ifr.ifr_name, intf, sizeof(ifr.ifr_name));
+    ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+    if (ioctl(ncf->driver->ioctl_fd, SIOCGIFFLAGS, &ifr))  {
+        return 0;
+    }
+    return ((ifr.ifr_flags & IFF_UP) == IFF_UP);
+}
+
+/*
+ * Test interface
+ */
+int _drv_get_aug(struct netcf *ncf, const char *ncf_xml, char **aug_xml) {
+    xmlDocPtr ncf_doc = NULL, aug_doc = NULL;
+    int result = -1;
+
+    ncf_doc = parse_xml(ncf, ncf_xml);
+    ERR_BAIL(ncf);
+
+    rng_validate(ncf, ncf_doc);
+    ERR_BAIL(ncf);
+
+    // FIXME: Check for errors from ApplyStylesheet
+    aug_doc = xsltApplyStylesheet(ncf->driver->get, ncf_doc, NULL);
+
+    xmlDocDumpFormatMemory(aug_doc, (xmlChar **) aug_xml, NULL, 1);
+    ERR_COND_BAIL(*aug_xml == NULL, ncf, EXMLINVALID);
+    /* fallthrough intentional */
+    result = 0;
+ error:
+    xmlFreeDoc(ncf_doc);
+    xmlFreeDoc(aug_doc);
+    return result;
+}
+
+/* Transform the Augeas XML AUG_XML into interface XML NCF_XML */
+int _drv_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml) {
+    xmlDocPtr ncf_doc = NULL, aug_doc = NULL;
+    int result = -1;
+
+    aug_doc = parse_xml(ncf, aug_xml);
+    ERR_BAIL(ncf);
+
+    // FIXME: Check for errors from ApplyStylesheet
+    ncf_doc = xsltApplyStylesheet(ncf->driver->put, aug_doc, NULL);
+
+    xmlDocDumpFormatMemory(ncf_doc, (xmlChar **) ncf_xml, NULL, 1);
+    ERR_COND_BAIL(*ncf_xml == NULL, ncf, EXMLINVALID);
+    /* fallthrough intentional */
+    result = 0;
+ error:
+    xmlFreeDoc(ncf_doc);
+    xmlFreeDoc(aug_doc);
+    return result;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
+/* vim: set ts=4 sw=4 et: */
diff --git a/src/dutil.h b/src/dutil.h
new file mode 100644
index 0000000..e5ec383
--- /dev/null
+++ b/src/dutil.h
@@ -0,0 +1,87 @@
+/*
+ * dutil.h: Global utility functions for driver backends.
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter at redhat.com>
+ */
+
+#ifndef DUTIL_H_
+#define DUTIL_H_
+
+#include <libxml/relaxng.h>
+#include <libxslt/xsltInternals.h>
+
+struct driver {
+    struct augeas     *augeas;
+    xsltStylesheetPtr  put;
+    xsltStylesheetPtr  get;
+    xmlRelaxNGPtr      rng;
+    int                ioctl_fd;
+    unsigned int       load_augeas : 1;
+};
+
+/* Like asprintf, but set *STRP to NULL on error */
+int xasprintf(char **strp, const char *format, ...);
+
+/* Free matches from aug_match (or aug_submatch) */
+void free_matches(int nint, char ***intf);
+
+/* Parse an XSLT stylesheet residing in the file @ncf->data_dir/xml/@fname */
+xsltStylesheetPtr parse_stylesheet(struct netcf *ncf, const char *fname);
+
+/* Callback for reporting RelaxNG errors */
+void rng_error(void *ctx, const char *format, ...);
+
+/* Initialize a rng pointer from the file @ncf->data_dir/xml/@fname */
+xmlRelaxNGPtr rng_parse(struct netcf *ncf, const char *fname);
+
+/* Validate the xml document doc using the previously initialized rng pointer */
+void rng_validate(struct netcf *ncf, xmlDocPtr doc);
+
+/* Called from SAX on parsing errors in the XML. */
+void catch_xml_error(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...);
+
+/* Parse the xml in @xml_str and return a xmlDocPtr to the parsed structure */
+xmlDocPtr parse_xml(struct netcf *ncf, const char *xml_str);
+
+/* Return the content the property @name in @node */
+char *xml_prop(xmlNodePtr node, const char *name);
+
+/* Get a file descriptor to a ioctl socket */
+int init_ioctl_fd(struct netcf *ncf);
+
+/* Check if the interface @intf is up using a ioctl call */
+int is_active(struct netcf *ncf, const char *intf);
+
+/* Transform the interface XML NCF_XML into Augeas XML AUG_XML */
+int _drv_get_aug(struct netcf *ncf, const char *ncf_xml, char **aug_xml);
+
+/* Transform the Augeas XML AUG_XML into interface XML NCF_XML */
+int _drv_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml);
+
+#endif
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
+/* vim: set ts=4 sw=4 et: */
-- 
1.6.2



More information about the netcf-devel mailing list