Fix the mess with ldb includes.
[abartlet/samba.git/.git] / source4 / lib / ldb / common / ldb_parse.c
index 939bf31eb9cb70c66b91a36a3d2631fd1a175cf4..654a635abf1d7edb016659d2de3b965b2f1063a7 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/>.
 */
 
 /*
@@ -41,8 +40,8 @@
 
 */
 
-#include "includes.h"
-#include "ldb/include/includes.h"
+#include "ldb_private.h"
+#include "system/locale.h"
 
 /*
 a filter is defined by:
@@ -66,7 +65,7 @@ struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str)
        struct ldb_val ret;
        int slen = str?strlen(str):0;
 
-       ret.data = talloc_size(mem_ctx, slen+1);
+       ret.data = (uint8_t *)talloc_size(mem_ctx, slen+1);
        ret.length = 0;
        if (ret.data == NULL) return ret;
 
@@ -133,7 +132,7 @@ char *ldb_binary_encode(void *mem_ctx, struct ldb_val val)
 char *ldb_binary_encode_string(void *mem_ctx, const char *string)
 {
        struct ldb_val val;
-       val.data = discard_const(string);
+       val.data = discard_const_p(uint8_t, string);
        val.length = strlen(string);
        return ldb_binary_encode(mem_ctx, val);
 }
@@ -264,6 +263,10 @@ static enum ldb_parse_op ldb_parse_filtertype(void *mem_ctx, char **type, char *
        /* retrieve attributetype name */
        t = p;
 
+       if (*p == '@') { /* for internal attributes the first char can be @ */
+               p++;
+       }
+
        while ((isascii(*p) && isalnum((unsigned char)*p)) || (*p == '-')) { /* attribute names can only be alphanums */
                p++;
        }
@@ -284,7 +287,7 @@ static enum ldb_parse_op ldb_parse_filtertype(void *mem_ctx, char **type, char *
        }
 
        /* save name */
-       name = talloc_memdup(mem_ctx, t, t1 - t + 1);
+       name = (char *)talloc_memdup(mem_ctx, t, t1 - t + 1);
        if (name == NULL) return 0;
        name[t1 - t] = '\0';
 
@@ -320,12 +323,12 @@ static enum ldb_parse_op ldb_parse_filtertype(void *mem_ctx, char **type, char *
 
        while (isspace((unsigned char)*p)) p++;
 
-       /* retieve value */
+       /* retrieve value */
        t = p;
 
        while (*p && ((*p != ')') || ((*p == ')') && (*(p - 1) == '\\')))) p++;
 
-       val = talloc_memdup(mem_ctx, t, p - t + 1);
+       val = (char *)talloc_memdup(mem_ctx, t, p - t + 1);
        if (val == NULL) {
                talloc_free(name);
                return 0;