From e2f3e10b1a47e195e9b329ac244be93c2fcdf0a0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 10 Oct 2010 23:45:23 +0200 Subject: ldb-samba: Rename samdb_relative_path to ldb_relative_path, as it's not samdb-specific. --- source4/lib/ldb-samba/ldb_wrap.c | 26 ++++++++++++++++++++++++++ source4/lib/ldb-samba/ldb_wrap.h | 3 +++ 2 files changed, 29 insertions(+) (limited to 'source4/lib/ldb-samba') diff --git a/source4/lib/ldb-samba/ldb_wrap.c b/source4/lib/ldb-samba/ldb_wrap.c index 7ac94dea2c..b09e68c0a1 100644 --- a/source4/lib/ldb-samba/ldb_wrap.c +++ b/source4/lib/ldb-samba/ldb_wrap.c @@ -338,3 +338,29 @@ int samba_ldb_connect(struct ldb_context *ldb, struct loadparm_context *lp_ctx, } } + char *ldb_relative_path(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + const char *name) +{ + const char *base_url = + (const char *)ldb_get_opaque(ldb, "ldb_url"); + char *path, *p, *full_name; + if (name == NULL) { + return NULL; + } + if (strncmp("tdb://", base_url, 6) == 0) { + base_url = base_url+6; + } + path = talloc_strdup(mem_ctx, base_url); + if (path == NULL) { + return NULL; + } + if ( (p = strrchr(path, '/')) != NULL) { + p[0] = '\0'; + full_name = talloc_asprintf(mem_ctx, "%s/%s", path, name); + } else { + full_name = talloc_asprintf(mem_ctx, "./%s", name); + } + talloc_free(path); + return full_name; +} diff --git a/source4/lib/ldb-samba/ldb_wrap.h b/source4/lib/ldb-samba/ldb_wrap.h index a835f665fc..531aa9ac70 100644 --- a/source4/lib/ldb-samba/ldb_wrap.h +++ b/source4/lib/ldb-samba/ldb_wrap.h @@ -60,5 +60,8 @@ bool ldb_wrap_add(const char *url, struct tevent_context *ev, struct cli_credentials *credentials, int flags, struct ldb_context *ldb); +char *ldb_relative_path(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + const char *name); #endif /* _LDB_WRAP_H_ */ -- cgit