Fix the mess with ldb includes.
[kamenim/samba.git] / source4 / lib / ldb / ldb_tdb / ldb_pack.c
index 258c54356cdb63470a0d5ed3a32d6badfec4eb40..1995606f88042a0595db1ba89e59c0a7b9731f7c 100644 (file)
@@ -10,7 +10,7 @@
    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 of the License, or (at your option) any later version.
+   version 3 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
@@ -18,8 +18,7 @@
    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
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
  *  Author: Andrew Tridgell
  */
 
-#include "includes.h"
-#include "ldb/include/includes.h"
-
-#include "ldb/ldb_tdb/ldb_tdb.h"
+#include "ldb_tdb.h"
 
 /* change this if the data format ever changes */
 #define LTDB_PACKING_FORMAT 0x26011967
@@ -82,14 +78,16 @@ int ltdb_pack_data(struct ldb_module *module,
                   const struct ldb_message *message,
                   struct TDB_DATA *data)
 {
-       struct ldb_context *ldb = module->ldb;
+       struct ldb_context *ldb;
        unsigned int i, j, real_elements=0;
        size_t size;
-       char *dn;
+       const char *dn;
        uint8_t *p;
        size_t len;
 
-       dn = ldb_dn_linearize(ldb, message->dn);
+       ldb = ldb_module_get_ctx(module);
+
+       dn = ldb_dn_get_linearized(message->dn);
        if (dn == NULL) {
                errno = ENOMEM;
                return -1;
@@ -116,7 +114,6 @@ int ltdb_pack_data(struct ldb_module *module,
        /* allocate it */
        data->dptr = talloc_array(ldb, uint8_t, size);
        if (!data->dptr) {
-               talloc_free(dn);
                errno = ENOMEM;
                return -1;
        }
@@ -151,7 +148,6 @@ int ltdb_pack_data(struct ldb_module *module,
                }
        }
 
-       talloc_free(dn);
        return 0;
 }
 
@@ -164,13 +160,14 @@ int ltdb_unpack_data(struct ldb_module *module,
                     const struct TDB_DATA *data,
                     struct ldb_message *message)
 {
-       struct ldb_context *ldb = module->ldb;
+       struct ldb_context *ldb;
        uint8_t *p;
        unsigned int remaining;
        unsigned int i, j;
        unsigned format;
        size_t len;
 
+       ldb = ldb_module_get_ctx(module);
        message->elements = NULL;
 
        p = data->dptr;