summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/include
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-11-16 09:00:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:52 -0500
commit8a18778286a16423d7d6e483fdb308a91e294efe (patch)
treeb1cf6a44c1cb4deccb04897ab426a724204b3f52 /source4/lib/ldb/include
parente81157c7379116d83b9906e27c9fd418c779d129 (diff)
downloadsamba-8a18778286a16423d7d6e483fdb308a91e294efe.tar.gz
samba-8a18778286a16423d7d6e483fdb308a91e294efe.tar.bz2
samba-8a18778286a16423d7d6e483fdb308a91e294efe.zip
r3783: - don't use make proto for ldb anymore
- split ldh.h out of samba's includes.h - make ldb_context and ldb_module private to the subsystem - use ltdb_ prefix for all ldb_tdb functions metze (This used to be commit f5ee40d6ce8224e280070975efc9911558fe675c)
Diffstat (limited to 'source4/lib/ldb/include')
-rw-r--r--source4/lib/ldb/include/includes.h8
-rw-r--r--source4/lib/ldb/include/ldb.h93
-rw-r--r--source4/lib/ldb/include/ldb_parse.h3
-rw-r--r--source4/lib/ldb/include/ldb_private.h126
4 files changed, 167 insertions, 63 deletions
diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h
index 44ff672266..4926e1524a 100644
--- a/source4/lib/ldb/include/includes.h
+++ b/source4/lib/ldb/include/includes.h
@@ -19,14 +19,8 @@
#include <sys/time.h>
#include <time.h>
-
-#ifndef _PRINTF_ATTRIBUTE
-#define _PRINTF_ATTRIBUTE(a,b)
-#endif
-
#include "ldb.h"
-#include "tdb.h"
-#include "proto.h"
+#include "ldb_private.h"
#ifdef HAVE_INTPTR_T
#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 6a06678e0e..03d0cc7a3b 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -121,39 +121,7 @@ struct ldb_context;
typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *);
-struct ldb_module_ops;
-
-/* basic module structure */
-struct ldb_module {
- struct ldb_module *prev, *next;
- struct ldb_context *ldb;
- void *private_data;
- const struct ldb_module_ops *ops;
-};
-
-/*
- these function pointers define the operations that a ldb module must perform
- they correspond exactly to the ldb_*() interface
-*/
-struct ldb_module_ops {
- const char *name;
- int (*close)(struct ldb_module *);
- int (*search)(struct ldb_module *, const char *, enum ldb_scope,
- const char *, const char * const [], struct ldb_message ***);
- int (*search_free)(struct ldb_module *, struct ldb_message **);
- int (*add_record)(struct ldb_module *, const struct ldb_message *);
- int (*modify_record)(struct ldb_module *, const struct ldb_message *);
- int (*delete_record)(struct ldb_module *, const char *);
- int (*rename_record)(struct ldb_module *, const char *, const char *);
- const char * (*errstring)(struct ldb_module *);
-
- /* this is called when the alloc ops changes to ensure we
- don't have any old allocated data in the context */
- void (*cache_free)(struct ldb_module *);
-};
-
-/* the modules init function */
-typedef struct ldb_module *(*init_ldb_module_function)(void);
+struct ldb_module;
/*
the user can optionally supply a allocator function. It is presumed
@@ -180,22 +148,6 @@ struct ldb_debug_ops {
void *context;
};
-
-/*
- every ldb connection is started by establishing a ldb_context
-*/
-struct ldb_context {
- /* the operations provided by the backend */
- struct ldb_module *modules;
-
- /* memory allocation info */
- struct ldb_alloc_ops alloc_ops;
-
- /* memory allocation info */
- struct ldb_debug_ops debug_ops;
-};
-
-
#define LDB_FLG_RDONLY 1
/*
@@ -285,6 +237,9 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif
/* useful functions for ldb_message structure manipulation */
+int ldb_dn_cmp(const char *dn1, const char *dn2);
+int ldb_attr_cmp(const char *dn1, const char *dn2);
+
/* find an element within an message */
struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg,
const char *attr_name);
@@ -305,6 +260,12 @@ int ldb_msg_add(struct ldb_context *ldb,
struct ldb_message *msg,
const struct ldb_message_element *el,
int flags);
+int ldb_msg_add_value(struct ldb_context *ldb,
+ struct ldb_message *msg,
+ const char *attr_name,
+ struct ldb_val *val);
+int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg,
+ const char *attr_name, char *str);
/* compare two message elements - return 0 on match */
int ldb_msg_element_compare(struct ldb_message_element *el1,
@@ -313,19 +274,27 @@ int ldb_msg_element_compare(struct ldb_message_element *el1,
/* find elements in a message and convert to a specific type, with
a give default value if not found. Assumes that elements are
single valued */
+const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, const char *attr_name);
int ldb_msg_find_int(const struct ldb_message *msg,
const char *attr_name,
int default_value);
unsigned int ldb_msg_find_uint(const struct ldb_message *msg,
const char *attr_name,
unsigned int default_value);
+int64_t ldb_msg_find_int64(const struct ldb_message *msg,
+ const char *attr_name,
+ int64_t default_value);
+uint64_t ldb_msg_find_uint64(const struct ldb_message *msg,
+ const char *attr_name,
+ uint64_t default_value);
double ldb_msg_find_double(const struct ldb_message *msg,
const char *attr_name,
double default_value);
const char *ldb_msg_find_string(const struct ldb_message *msg,
const char *attr_name,
const char *default_value);
-
+struct ldb_val ldb_val_dup(struct ldb_context *ldb,
+ const struct ldb_val *v);
/*
this allows the user to choose their own allocation function
@@ -341,6 +310,24 @@ int ldb_set_alloc(struct ldb_context *ldb,
void *(*alloc)(const void *context, void *ptr, size_t size),
void *context);
+/* these are used as type safe versions of the ldb allocation functions */
+#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type))
+#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count)
+#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count)
+
+void *ldb_realloc(struct ldb_context *ldb, void *ptr, size_t size);
+void *ldb_malloc(struct ldb_context *ldb, size_t size);
+void ldb_free(struct ldb_context *ldb, void *ptr);
+void *ldb_strndup(struct ldb_context *ldb, const char *str, size_t maxlen);
+void *ldb_strdup(struct ldb_context *ldb, const char *str);
+void *ldb_realloc_array(struct ldb_context *ldb,
+ void *ptr, size_t el_size, unsigned count);
+
+#ifndef PRINTF_ATTRIBUTE
+#define PRINTF_ATTRIBUTE(a,b)
+#endif
+int ldb_asprintf(struct ldb_context *ldb, char **strp, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+
/*
this allows the user to set a debug function for error reporting
*/
@@ -352,10 +339,4 @@ int ldb_set_debug(struct ldb_context *ldb,
/* this sets up debug to print messages on stderr */
int ldb_set_debug_stderr(struct ldb_context *ldb);
-
-/* these are used as type safe versions of the ldb allocation functions */
-#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type))
-#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count)
-#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count)
-
#endif
diff --git a/source4/lib/ldb/include/ldb_parse.h b/source4/lib/ldb/include/ldb_parse.h
index 930799d7b6..d9125d05ed 100644
--- a/source4/lib/ldb/include/ldb_parse.h
+++ b/source4/lib/ldb/include/ldb_parse.h
@@ -54,4 +54,7 @@ struct ldb_parse_tree {
} u;
};
+struct ldb_parse_tree *ldb_parse_tree(struct ldb_context *ldb, const char *s);
+void ldb_parse_tree_free(struct ldb_context *ldb, struct ldb_parse_tree *tree);
+
#endif
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
new file mode 100644
index 0000000000..dfd388b8c6
--- /dev/null
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -0,0 +1,126 @@
+/*
+ ldb database library
+
+ Copyright (C) Andrew Tridgell 2004
+ Copyright (C) Stefan Metzmacher 2004
+
+ ** NOTE! The following LGPL license applies to the ldb
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+
+ 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.
+
+ 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
+*/
+
+/*
+ * Name: ldb
+ *
+ * Component: ldb private header
+ *
+ * Description: defines internal ldb structures used by th esubsystem and modules
+ *
+ * Author: Andrew Tridgell
+ * Author: Stefan Metzmacher
+ */
+
+#ifndef _LDB_PRIVATE_H_
+#define _LDB_PRIVATE_H_ 1
+
+struct ldb_context;
+
+struct ldb_module_ops;
+
+/* basic module structure */
+struct ldb_module {
+ struct ldb_module *prev, *next;
+ struct ldb_context *ldb;
+ void *private_data;
+ const struct ldb_module_ops *ops;
+};
+
+/*
+ these function pointers define the operations that a ldb module must perform
+ they correspond exactly to the ldb_*() interface
+*/
+struct ldb_module_ops {
+ const char *name;
+ int (*close)(struct ldb_module *);
+ int (*search)(struct ldb_module *, const char *, enum ldb_scope,
+ const char *, const char * const [], struct ldb_message ***);
+ int (*search_free)(struct ldb_module *, struct ldb_message **);
+ int (*add_record)(struct ldb_module *, const struct ldb_message *);
+ int (*modify_record)(struct ldb_module *, const struct ldb_message *);
+ int (*delete_record)(struct ldb_module *, const char *);
+ int (*rename_record)(struct ldb_module *, const char *, const char *);
+ const char * (*errstring)(struct ldb_module *);
+
+ /* this is called when the alloc ops changes to ensure we
+ don't have any old allocated data in the context */
+ void (*cache_free)(struct ldb_module *);
+};
+
+/* the modules init function */
+typedef struct ldb_module *(*ldb_module_init_function)(void);
+
+/*
+ every ldb connection is started by establishing a ldb_context
+*/
+struct ldb_context {
+ /* the operations provided by the backend */
+ struct ldb_module *modules;
+
+ /* memory allocation info */
+ struct ldb_alloc_ops alloc_ops;
+
+ /* memory allocation info */
+ struct ldb_debug_ops debug_ops;
+};
+
+/* The following definitions come from lib/ldb/common/ldb_modules.c */
+
+int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
+int ldb_next_close(struct ldb_module *module);
+int ldb_next_search(struct ldb_module *module,
+ const char *base,
+ enum ldb_scope scope,
+ const char *expression,
+ const char * const *attrs, struct ldb_message ***res);
+int ldb_next_search_free(struct ldb_module *module, struct ldb_message **msg);
+int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message);
+int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message);
+int ldb_next_delete_record(struct ldb_module *module, const char *dn);
+int ldb_next_rename_record(struct ldb_module *module, const char *olddn, const char *newdn);
+const char *ldb_next_errstring(struct ldb_module *module);
+void ldb_next_cache_free(struct ldb_module *module);
+
+/* The following definitions come from lib/ldb/common/util.c */
+int ldb_list_find(const void *needle,
+ const void *base, size_t nmemb, size_t size, comparison_fn_t comp_fn);
+
+/* The following definitions come from lib/ldb/common/ldb_debug.c */
+void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+
+/* The following definitions come from lib/ldb/common/ldb_ldif.c */
+char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len);
+int ldb_should_b64_encode(const struct ldb_val *val);
+
+struct ldb_context *ltdb_connect(const char *url,
+ unsigned int flags,
+ const char *options[]);
+struct ldb_context *lldb_connect(const char *url,
+ unsigned int flags,
+ const char *options[]);
+struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]);
+
+#endif