From b6abf79d60722dbee89e6270435d0b11c0dffa91 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 30 Nov 2003 14:27:42 +0000 Subject: relase 0.3 --copy-always --sort bi-directory merges --check-md git-svn-id: file:///home/lennart/svn/public/syrep/trunk@43 07ea20a6-d2c5-0310-9e02-9ef735347d72 --- src/dbutil.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/dbutil.c') diff --git a/src/dbutil.c b/src/dbutil.c index d7aa319..cfa3150 100644 --- a/src/dbutil.c +++ b/src/dbutil.c @@ -18,6 +18,10 @@ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***/ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -152,6 +156,14 @@ int get_current_md_by_nrecno(struct syrep_db_context *c, const struct syrep_nrec return 1; } +int get_current_md_by_name(struct syrep_db_context *c, const struct syrep_name *name, struct syrep_md *md) { + struct syrep_nrecno nrecno; + + if (get_nrecno_by_name(c, name, &nrecno, 0) < 0) + return -1; + + return get_current_md_by_nrecno(c, &nrecno, md); +} uint32_t get_version_timestamp(struct syrep_db_context *c, uint32_t v) { DBT key, data; @@ -210,7 +222,8 @@ int get_name_by_nrecno(struct syrep_db_context *c, const struct syrep_nrecno *nr if (name) { memset(name, 0, sizeof(struct syrep_name)); - strncpy(name->path, data.data, MIN(PATH_MAX, data.size)); + strncpy(name->path, data.data, MIN(PATH_MAX-1, data.size)); + name->path[PATH_MAX-1] = 0; } return 1; -- cgit