- Expanded usage string.
- Parse argv[ 0 ] for a backslash for Window support.
- Forward declare str_parse_line() and str_getline() to quite
compiler warnings for Microsoft compiler.
- Test argc for no parameters and display usage text.
- Bug: The third parameter of ldap_set_options() needs to
be a pointer to an int per draft-ietf-ldapext-ldap-c-api-01.txt.
- Print the results of ldif_rec() and ldapmod_rec().
- Bug: Create local versions of l_ber_bvfree and l_ber_bvecfree()
per draft-ietf-ldapext-ldap-c-api-01.txt. When using a windows
LDAP DLL library we need local versions of the berval
free functions because the LDAP DLL uses a different
heap.
- One additional thought: Another usage description for the new
-W option could be added.
Thanks,
--
-
J. R. Heisey
------------------------------------------------------------
--- ldapmodify.c Tue Feb 23 17:06:40 1999
+++ w:/openldap/ldap.dev/clients/tools/ldapmodify.c Mon Dec 14
17:00:10 1998
@@ -52,7 +52,4 @@
-int str_parse_line LDAP_P(( char *line, char **type, char **value,
int *vlen));
-char * str_getline LDAP_P(( char **next ));
-
static int process_ldapmod_rec LDAP_P(( char *rbuf ));
static int process_ldif_rec LDAP_P(( char *rbuf ));
@@ -73,36 +70,11 @@
FILE *fp;
int rc, i, use_ldif, authmethod,
want_bindpw;
- char
*usage = "Add or modify entries from an LDAP server\n\n"
-
"usage: %s [-abcknrvF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D
binddn] [-w passwd] [ -f file | < entryfile ]\n"
-
" a - add values
(default is to replace )\n"
-
" b - read values
from files (for binary attributes)\n"
-
" c - continuous
operation\n"
-
" D - bind DN\n"
-
" d - debug level\n"
-
" f - read from file\n"
-
" F - force all changes
records to be used\n"
-
" h - ldap host\n"
-
" n - print adds,
don't actually do them\n"
-
" p - LDAP port\n"
-
" r - replace values\n"
-
" v - verbose mode\n"
-
" w - password\n"
-
;
- int
deref;
-
- if (( prog = strrchr( argv[ 0 ], '/'
)) == NULL &&
- ( prog = strrchr( argv[
0 ], '\\' )) == NULL ) { // for Windows/DOS
- prog = argv[ 0 ];
+ char *usage = "usage: %s [-abcknrvWF]
[-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [
-f file | < entryfile ]\n";
+
+ if (( prog = strrchr( argv[ 0 ], '/' )) ==
NULL ) {
+ prog = argv[ 0 ];
} else {
++prog;
}
-
- // Print usage when no parameters
- if( argc < 2 )
- {
- fprintf( stderr, usage, prog );
- exit( 1 );
- }
-
new = ( strcmp( prog, "ldapadd" ) == 0
);
@@ -201,10 +173,9 @@
}
- deref = LDAP_DEREF_NEVER;
- /* this seems prudent */
- ldap_set_option( ld, LDAP_OPT_DEREF, &deref
);
+ /* this seems prudent */
+ ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
@@ -247,8 +218,5 @@
}
- if( rc )
-
fprintf( stderr, "%s() = %d\n", use_ldif ? "ldif_rec" : "ldapmod_rec" ,
rc );
-
- free( rbuf );
+ free( rbuf );
}
@@ -734,31 +702,5 @@
}
-// for Windows we need local versions of the berval
-// free functions because the LDAP DLL uses a different
-// help.
-static void
-LDAP_CALL
-l_ber_bvfree( struct berval *bv )
-{
- if ( bv != NULL ) {
- if ( bv->bv_val != NULL ) {
- free( bv->bv_val );
- }
- free( (char *) bv );
- }
-}
-
-static void
-LDAP_CALL
-l_ber_bvecfree( struct berval **bv )
-{
- int i;
-
- for ( i = 0; bv[i] != NULL; i++ ) {
- l_ber_bvfree( bv[i] );
- }
- free( (char *) bv );
-}
static void
@@ -769,5 +711,5 @@
for ( i = 0; pmods[ i ] != NULL; ++i )
{
if ( pmods[ i ]->mod_bvalues != NULL ) {
-
l_ber_bvecfree( pmods[ i ]->mod_bvalues );
+ ber_bvecfree( pmods[ i ]->mod_bvalues
);
}
if ( pmods[ i ]->mod_type != NULL ) {
begin:vcard n:Heisey;J.R. tel;fax:408-248-8552 tel;work:408-248-9495 x117 x-mozilla-html:FALSE url:www.mediagate.com org:MediaGate Inc. adr:;;1245 S. Winchester Blvd.;San Jose;CA;95128;USA version:2.1 email;internet:jr.heisey@mediagate.com title:Sr. Foundation Engineer note:Currently working on LDAP client software. end:vcard