Import Julio ldif2ldbm fixes from devel.

This commit is contained in:
Kurt Zeilenga 1999-07-31 04:02:52 +00:00
parent a1f409edd3
commit 02084bdcb4
2 changed files with 11 additions and 5 deletions

View file

@ -239,7 +239,11 @@ main( int argc, char **argv )
}
if ( line[0] == '\n' || stop && buf && *buf ) {
if ( * buf != '\n' ) {
id++;
if (isdigit((unsigned char) *buf)) {
id = atol(buf);
} else {
id++;
}
s = buf;
while ( (linep = str_getline( &s )) != NULL ) {
if ( str_parse_line( linep, &type, &val,

View file

@ -34,7 +34,7 @@ main( int argc, char **argv )
char line[BUFSIZ], idbuf[BUFSIZ];
int lmax, lcur;
int dbnum;
ID id;
ID id, maxid;
struct dbcache *db;
Backend *be = NULL;
struct ldbminfo *li;
@ -116,6 +116,7 @@ main( int argc, char **argv )
}
id = 0;
maxid = 0;
stop = 0;
buf = NULL;
lcur = lmax = 0;
@ -164,6 +165,7 @@ main( int argc, char **argv )
int len;
id++;
if( id > maxid ) maxid = id;
key.dptr = (char *) &id;
key.dsize = sizeof(ID);
data.dptr = buf;
@ -185,14 +187,14 @@ main( int argc, char **argv )
}
(*be->be_close)( be );
id++;
maxid++;
sprintf( line, "%s/NEXTID",
((struct ldbminfo *) be->be_private)->li_directory );
if ( (fp = fopen( line, "w" )) == NULL ) {
perror( line );
fprintf( stderr, "Could not write next id %ld\n", id );
fprintf( stderr, "Could not write next id %ld\n", maxid );
} else {
fprintf( fp, "%ld\n", id );
fprintf( fp, "%ld\n", maxid );
fclose( fp );
}