From 8a884d1b9cd6d0dfb8260214c7fcba57c8b322ea Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 30 Nov 1998 22:26:11 +0000 Subject: [PATCH] Add ldif2ldbm bugfix from Randy Kunkee --- servers/slapd/tools/ldif2id2children.c | 8 +++++++- servers/slapd/tools/ldif2id2entry.c | 18 +++++++++++++++--- servers/slapd/tools/ldif2index.c | 8 +++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/servers/slapd/tools/ldif2id2children.c b/servers/slapd/tools/ldif2id2children.c index 5e709dc9bc..30dffcf688 100644 --- a/servers/slapd/tools/ldif2id2children.c +++ b/servers/slapd/tools/ldif2id2children.c @@ -1,7 +1,9 @@ #include "portable.h" #include +#include +#include #include #include #include @@ -163,7 +165,11 @@ main( int argc, char **argv ) } if ( line[0] == '\n' || stop && buf && *buf ) { if ( *buf != '\n' ) { - id++; + if (isdigit(*buf)) { + id = atol(buf); + } else { + id++; + } s = buf; elineno = 0; while ( (linep = str_getline( &s )) != NULL ) { diff --git a/servers/slapd/tools/ldif2id2entry.c b/servers/slapd/tools/ldif2id2entry.c index 19d13a44c5..903c8b8d42 100644 --- a/servers/slapd/tools/ldif2id2entry.c +++ b/servers/slapd/tools/ldif2id2entry.c @@ -1,7 +1,9 @@ #include "portable.h" #include +#include +#include #include #include #include @@ -144,8 +146,13 @@ main( int argc, char **argv ) len = strlen( line ); if ( buf == NULL || *buf == '\0' ) { - sprintf( idbuf, "%lu\n", id + 1 ); - idlen = strlen( idbuf ); + if (!isdigit(line[0])) { + sprintf( idbuf, "%d\n", id + 1 ); + idlen = strlen( idbuf ); + } else { + id = atol(line) - 1; + idlen = 0; + } } else { idlen = 0; } @@ -166,11 +173,16 @@ main( int argc, char **argv ) } if ( line[0] == '\n' || stop && buf && *buf ) { if ( *buf != '\n' ) { + int len; + id++; key.dptr = (char *) &id; key.dsize = sizeof(ID); data.dptr = buf; - data.dsize = strlen( buf ) + 1; + len = strlen(buf); + if (buf[len - 1] == '\n') + buf[--len] = '\0'; + data.dsize = len + 1; if ( ldbm_store( db->dbc_db, key, data, LDBM_INSERT ) != 0 ) { fputs("id2entry ldbm_store failed\n", diff --git a/servers/slapd/tools/ldif2index.c b/servers/slapd/tools/ldif2index.c index 1287f502d0..918a054d99 100644 --- a/servers/slapd/tools/ldif2index.c +++ b/servers/slapd/tools/ldif2index.c @@ -1,7 +1,9 @@ #include "portable.h" #include +#include +#include #include #include #include @@ -151,7 +153,11 @@ main( int argc, char **argv ) } if ( line[0] == '\n' || stop && buf && *buf ) { if ( *buf != '\n' ) { - id++; + if (isdigit(*buf)) { + id = atol(buf); + } else { + id++; + } s = buf; elineno = 0; while ( (linep = str_getline( &s )) != NULL ) { -- 2.39.5