]> git.sur5r.net Git - openldap/commitdiff
Add ldif2ldbm bugfix from Randy Kunkee <kunkee@pluto.ops.NeoSoft.com>
authorKurt Zeilenga <kurt@openldap.org>
Mon, 30 Nov 1998 22:26:11 +0000 (22:26 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 30 Nov 1998 22:26:11 +0000 (22:26 +0000)
servers/slapd/tools/ldif2id2children.c
servers/slapd/tools/ldif2id2entry.c
servers/slapd/tools/ldif2index.c

index 5e709dc9bc44d5387f9784823d4563b82d7dc57d..30dffcf6882d7bbd53b5a43baef05f24cd00fdd4 100644 (file)
@@ -1,7 +1,9 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
+#include <ac/ctype.h>
 #include <ac/string.h>
 #include <ac/socket.h>
 #include <ac/unistd.h>
@@ -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 ) {
index 19d13a44c557aa0f32f3039da9544c57d73a0441..903c8b8d42c0a85513eea685f277e4827ca1a979 100644 (file)
@@ -1,7 +1,9 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
+#include <ac/ctype.h>
 #include <ac/string.h>
 #include <ac/socket.h>
 #include <ac/unistd.h>
@@ -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",
index 1287f502d08f40eddce01fb70debe7a453c0a99a..918a054d99fd1ed68230d89ecc4ab5fab592a94a 100644 (file)
@@ -1,7 +1,9 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
+#include <ac/ctype.h>
 #include <ac/string.h>
 #include <ac/socket.h>
 #include <ac/unistd.h>
@@ -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 ) {