+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
#include "portable.h"
#include <stdio.h>
#include <io.h>
#endif
-#include "ldapconfig.h"
+#include "ldap_defaults.h"
#include "../slap.h"
#include "../back-ldbm/back-ldbm.h"
-static struct dbcache *openchoice(char c, int mode, int verbose, char **fname);
+static DBCache *openchoice(char c, int mode, int verbose, char **fname);
static void print_entry(FILE *fp, char c, Datum *key, char *klabel, Datum *data, char *dlabel);
-static void free_and_close(struct dbcache *dbc, Datum key, Datum data);
+static void free_and_close(DBCache *dbc, Datum key, Datum data);
static void edit_entry(char c, Datum *data);
static void get_keydata(FILE *fp, char c, Datum *key, Datum *data);
-static struct dbcache *dbc;
+static DBCache *dbc;
static LDBM dbp;
static Backend *be = NULL;
char buf[256];
Datum savekey, key, data, last;
char *fname;
- ID id;
+ ID id, cursor;
ID_BLOCK *idl;
Backend *tbe;
int i;
fprintf( stderr,
"usage: %s [-d level] [-f slapdconfigfile]\n",
argv[0] );
- exit( -1 );
- break;
+ exit( EXIT_FAILURE );
}
}
free_and_close( dbc, key, data );
break;
+#ifndef HAVE_WINSOCK
case 'e': /* edit an entry */
if ( (dbc = openchoice( buf[1], LDBM_WRITER, 1, NULL ))
== NULL ) {
free_and_close( dbc, key, data );
break;
+#endif
case 'a': /* add an entry */
if ( (dbc = openchoice( buf[1], LDBM_WRITER, 1, NULL ))
get_keydata( stdin, buf[1], &key, &data );
idl = (ID_BLOCK *) data.dptr;
- for ( id = idl_firstid( idl ); id != NOID;
- id = idl_nextid( idl, id ) ) {
+ for ( id = idl_firstid( idl, &cursor ); id != NOID;
+ id = idl_nextid( idl, &cursor ) ) {
if ( idl_insert_key( be, dbc, key, id )
!= 0 ) {
fprintf( stderr,
printf( "suffix: " );
fflush( stdout );
if ( fgets( buf, sizeof(buf), stdin ) == NULL ) {
- exit( 0 );
+ exit( EXIT_SUCCESS );
} else {
buf[strlen( buf ) - 1] = '\0';
}
slap_shutdown(-1);
slap_destroy();
- return( 0 );
+ return( EXIT_SUCCESS );
}
static void
-free_and_close( struct dbcache *dbc, Datum key, Datum data )
+free_and_close( DBCache *dbc, Datum key, Datum data )
{
ldbm_cache_really_close( be, dbc );
if ( key.dptr != NULL )
data->dsize = psize + 1;
}
+#ifndef HAVE_WINSOCK
static void
edit_entry( char c, Datum *data )
{
char *editor;
if ( (editor = getenv( "EDITOR" )) == NULL ) {
- editor = DEFAULT_EDITOR;
+ editor = LDAP_EDITOR;
}
execl( editor, editor, tmpname, NULL );
perror( "execl" );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
fclose( fp );
fclose( fp );
unlink( tmpname );
}
+#endif
-static struct dbcache *
+static DBCache *
openfile( char *name, int namesiz, int mode, int verbose, char c )
{
- struct dbcache *dbc;
+ DBCache *dbc;
if ( name == NULL || *name == '\0' ) {
if ( c == 'f' ) {
printf( " file: " );
if ( fgets( name, namesiz, stdin ) == NULL )
- exit( 0 );
+ exit( EXIT_SUCCESS );
name[strlen( name ) - 1] = '\0';
} else {
printf( " attr: " );
if ( fgets( name, namesiz, stdin ) == NULL )
- exit( 0 );
+ exit( EXIT_SUCCESS );
name[strlen( name ) - 1] = '\0';
}
}
return( dbc );
}
-static struct dbcache *
+static DBCache *
openchoice( char c, int mode, int verbose, char **fname )
{
static char name[MAXPATHLEN];
if ( tty )
printf( " dn: " );
if ( fgets( kbuf, sizeof(kbuf), fp ) == NULL ) {
- exit( 0 );
+ exit( EXIT_SUCCESS );
}
kbuf[strlen( kbuf ) - 1] = '\0';
key->dptr = strdup( kbuf );
if ( tty )
printf( " dnid: " );
if ( fgets( dbuf, sizeof(dbuf), fp ) == NULL ) {
- exit( 0 );
+ exit( EXIT_SUCCESS );
}
n = atol( dbuf );
data->dptr = (char *) malloc( sizeof(n) );
if ( tty )
printf( " dnid: " );
if ( fgets( kbuf, sizeof(kbuf), fp ) == NULL ) {
- exit( 0 );
+ exit( EXIT_SUCCESS );
}
n = atol( kbuf );
key->dptr = (char *) malloc( sizeof(n) );
if ( tty )
printf( " key: " );
if ( fgets( kbuf, sizeof(kbuf), fp ) == NULL ) {
- exit( 0 );
+ exit( EXIT_SUCCESS );
}
kbuf[strlen( kbuf ) - 1] = '\0';
key->dptr = strdup( kbuf );