Fix the mess with ldb includes.
[metze/samba/wip.git] / source4 / nbt_server / wins / wins_ldb.c
index f5f9e0e327cf23569c12facc6a113de1d1ad2c2d..7effb9b8420d229687f0d84085d1661d44c2b2c3 100644 (file)
@@ -5,7 +5,7 @@
 
    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
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
    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., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
@@ -29,6 +28,7 @@
  */
 
 #include "includes.h"
+#include "lib/events/events.h"
 #include "nbt_server/nbt_server.h"
 #include "nbt_server/wins/winsdb.h"
 #include "lib/ldb/include/ldb.h"
@@ -36,6 +36,7 @@
 #include "lib/ldb/include/ldb_private.h"
 #include "system/network.h"
 #include "lib/socket/netif.h"
+#include "param/param.h"
 
 static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req)
 {
@@ -84,18 +85,21 @@ static int wins_ldb_init(struct ldb_module *ctx)
 {
        struct winsdb_handle *h;
        const char *owner;
+       struct loadparm_context *lp_ctx = ldb_get_opaque(ctx->ldb, "loadparm");
 
        ctx->private_data = NULL;
 
-       owner = lp_parm_string(-1, "winsdb", "local_owner");
+       owner = lp_parm_string(lp_ctx, NULL, "winsdb", "local_owner");
        if (!owner) {
-               owner = iface_n_ip(0);
+               struct interface *ifaces;
+               load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces);
+               owner = iface_n_ip(ifaces, 0);
                if (!owner) {
                        owner = "0.0.0.0";
                }
        }
 
-       h = talloc(ctx, struct winsdb_handle);
+       h = talloc_zero(ctx, struct winsdb_handle);
        if (!h) goto failed;
        h->ldb          = ctx->ldb;
        h->caller       = WINSDB_HANDLE_CALLER_ADMIN;
@@ -109,16 +113,9 @@ failed:
        return LDB_ERR_OTHER;
 }
 
-static const struct ldb_module_ops wins_ldb_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_wins_ldb_module_ops = {
        .name          = "wins_ldb",
        .add           = wins_ldb_verify,
        .modify        = wins_ldb_verify,
        .init_context  = wins_ldb_init
 };
-
-
-/* the init function */
-int wins_ldb_module_init(void)
-{
-       return ldb_register_module(&wins_ldb_ops);
-}