Fix fprintf\'s, missing `prog\' argument

This commit is contained in:
Ben Collins 2000-09-15 02:48:10 +00:00
parent d3805f1980
commit bca61801a1
5 changed files with 67 additions and 70 deletions

View file

@ -112,7 +112,7 @@ main( int argc, char **argv )
break; break;
case 'f': /* read DNs from a file */ case 'f': /* read DNs from a file */
if( fp != NULL ) { if( fp != NULL ) {
fprintf( stderr, "%s: -f previously specified\n" ); fprintf( stderr, "%s: -f previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (( fp = fopen( optarg, "r" )) == NULL ) { if (( fp = fopen( optarg, "r" )) == NULL ) {
@ -133,33 +133,33 @@ main( int argc, char **argv )
break; break;
case 'D': /* bind DN */ case 'D': /* bind DN */
if( binddn != NULL ) { if( binddn != NULL ) {
fprintf( stderr, "%s: -D previously specified\n" ); fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
binddn = strdup( optarg ); binddn = strdup( optarg );
break; break;
case 'h': /* ldap host */ case 'h': /* ldap host */
if( ldapuri != NULL ) { if( ldapuri != NULL ) {
fprintf( stderr, "%s: -h incompatible with -H\n" ); fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldaphost != NULL ) { if( ldaphost != NULL ) {
fprintf( stderr, "%s: -h previously specified\n" ); fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldaphost = strdup( optarg ); ldaphost = strdup( optarg );
break; break;
case 'H': /* ldap URI */ case 'H': /* ldap URI */
if( ldaphost != NULL ) { if( ldaphost != NULL ) {
fprintf( stderr, "%s: -H incompatible with -h\n" ); fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldapport ) { if( ldapport ) {
fprintf( stderr, "%s: -H incompatible with -p\n" ); fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldapuri != NULL ) { if( ldapuri != NULL ) {
fprintf( stderr, "%s: -H previously specified\n" ); fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldapuri = strdup( optarg ); ldapuri = strdup( optarg );
@ -241,7 +241,7 @@ main( int argc, char **argv )
case 'O': case 'O':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) { if( sasl_secprops != NULL ) {
fprintf( stderr, "%s: -O previously specified\n" ); fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -265,7 +265,7 @@ main( int argc, char **argv )
break; break;
case 'p': case 'p':
if( ldapport ) { if( ldapport ) {
fprintf( stderr, "%s: -p previously specified\n" ); fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldapport = atoi( optarg ); ldapport = atoi( optarg );
@ -319,7 +319,7 @@ main( int argc, char **argv )
case 'R': case 'R':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) { if( sasl_realm != NULL ) {
fprintf( stderr, "%s: -R previously specified\n" ); fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -345,7 +345,7 @@ main( int argc, char **argv )
case 'U': case 'U':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) { if( sasl_authc_id != NULL ) {
fprintf( stderr, "%s: -U previously specified\n" ); fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -388,7 +388,7 @@ main( int argc, char **argv )
case 'Y': case 'Y':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) { if( sasl_mech != NULL ) {
fprintf( stderr, "%s: -Y previously specified\n" ); fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -420,7 +420,7 @@ main( int argc, char **argv )
case 'X': case 'X':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) { if( sasl_authz_id != NULL ) {
fprintf( stderr, "%s: -X previously specified\n" ); fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {

View file

@ -172,7 +172,7 @@ main( int argc, char **argv )
break; break;
case 'f': /* read from file */ case 'f': /* read from file */
if( infile != NULL ) { if( infile != NULL ) {
fprintf( stderr, "%s: -f previously specified\n" ); fprintf( stderr, "%s: -f previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
infile = strdup( optarg ); infile = strdup( optarg );
@ -193,33 +193,33 @@ main( int argc, char **argv )
break; break;
case 'D': /* bind DN */ case 'D': /* bind DN */
if( binddn != NULL ) { if( binddn != NULL ) {
fprintf( stderr, "%s: -D previously specified\n" ); fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
binddn = strdup( optarg ); binddn = strdup( optarg );
break; break;
case 'h': /* ldap host */ case 'h': /* ldap host */
if( ldapuri != NULL ) { if( ldapuri != NULL ) {
fprintf( stderr, "%s: -h incompatible with -H\n" ); fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldaphost != NULL ) { if( ldaphost != NULL ) {
fprintf( stderr, "%s: -h previously specified\n" ); fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldaphost = strdup( optarg ); ldaphost = strdup( optarg );
break; break;
case 'H': /* ldap URI */ case 'H': /* ldap URI */
if( ldaphost != NULL ) { if( ldaphost != NULL ) {
fprintf( stderr, "%s: -H incompatible with -h\n" ); fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldapport ) { if( ldapport ) {
fprintf( stderr, "%s: -H incompatible with -p\n" ); fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldapuri != NULL ) { if( ldapuri != NULL ) {
fprintf( stderr, "%s: -H previously specified\n" ); fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldapuri = strdup( optarg ); ldapuri = strdup( optarg );
@ -301,7 +301,7 @@ main( int argc, char **argv )
case 'O': case 'O':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) { if( sasl_secprops != NULL ) {
fprintf( stderr, "%s: -O previously specified\n" ); fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -325,7 +325,7 @@ main( int argc, char **argv )
break; break;
case 'p': case 'p':
if( ldapport ) { if( ldapport ) {
fprintf( stderr, "%s: -p previously specified\n" ); fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldapport = atoi( optarg ); ldapport = atoi( optarg );
@ -379,7 +379,7 @@ main( int argc, char **argv )
case 'R': case 'R':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) { if( sasl_realm != NULL ) {
fprintf( stderr, "%s: -R previously specified\n" ); fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -405,7 +405,7 @@ main( int argc, char **argv )
case 'U': case 'U':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) { if( sasl_authc_id != NULL ) {
fprintf( stderr, "%s: -U previously specified\n" ); fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -448,7 +448,7 @@ main( int argc, char **argv )
case 'Y': case 'Y':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) { if( sasl_mech != NULL ) {
fprintf( stderr, "%s: -Y previously specified\n" ); fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -480,7 +480,7 @@ main( int argc, char **argv )
case 'X': case 'X':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) { if( sasl_authz_id != NULL ) {
fprintf( stderr, "%s: -X previously specified\n" ); fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {

View file

@ -128,7 +128,7 @@ main(int argc, char **argv)
break; break;
case 'f': /* read from file */ case 'f': /* read from file */
if( infile != NULL ) { if( infile != NULL ) {
fprintf( stderr, "%s: -f previously specified\n" ); fprintf( stderr, "%s: -f previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
infile = strdup( optarg ); infile = strdup( optarg );
@ -155,33 +155,33 @@ main(int argc, char **argv)
break; break;
case 'D': /* bind DN */ case 'D': /* bind DN */
if( binddn != NULL ) { if( binddn != NULL ) {
fprintf( stderr, "%s: -D previously specified\n" ); fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
binddn = strdup( optarg ); binddn = strdup( optarg );
break; break;
case 'h': /* ldap host */ case 'h': /* ldap host */
if( ldapuri != NULL ) { if( ldapuri != NULL ) {
fprintf( stderr, "%s: -h incompatible with -H\n" ); fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldaphost != NULL ) { if( ldaphost != NULL ) {
fprintf( stderr, "%s: -h previously specified\n" ); fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldaphost = strdup( optarg ); ldaphost = strdup( optarg );
break; break;
case 'H': /* ldap URI */ case 'H': /* ldap URI */
if( ldaphost != NULL ) { if( ldaphost != NULL ) {
fprintf( stderr, "%s: -H incompatible with -h\n" ); fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldapport ) { if( ldapport ) {
fprintf( stderr, "%s: -H incompatible with -p\n" ); fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldapuri != NULL ) { if( ldapuri != NULL ) {
fprintf( stderr, "%s: -H previously specified\n" ); fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldapuri = strdup( optarg ); ldapuri = strdup( optarg );
@ -263,7 +263,7 @@ main(int argc, char **argv)
case 'O': case 'O':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) { if( sasl_secprops != NULL ) {
fprintf( stderr, "%s: -O previously specified\n" ); fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -287,7 +287,7 @@ main(int argc, char **argv)
break; break;
case 'p': case 'p':
if( ldapport ) { if( ldapport ) {
fprintf( stderr, "%s: -p previously specified\n" ); fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldapport = atoi( optarg ); ldapport = atoi( optarg );
@ -341,7 +341,7 @@ main(int argc, char **argv)
case 'R': case 'R':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) { if( sasl_realm != NULL ) {
fprintf( stderr, "%s: -R previously specified\n" ); fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -367,7 +367,7 @@ main(int argc, char **argv)
case 'U': case 'U':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) { if( sasl_authc_id != NULL ) {
fprintf( stderr, "%s: -U previously specified\n" ); fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -410,7 +410,7 @@ main(int argc, char **argv)
case 'Y': case 'Y':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) { if( sasl_mech != NULL ) {
fprintf( stderr, "%s: -Y previously specified\n" ); fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -442,7 +442,7 @@ main(int argc, char **argv)
case 'X': case 'X':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) { if( sasl_authz_id != NULL ) {
fprintf( stderr, "%s: -X previously specified\n" ); fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {

View file

@ -154,33 +154,33 @@ main( int argc, char *argv[] )
break; break;
case 'D': /* bind DN */ case 'D': /* bind DN */
if( binddn != NULL ) { if( binddn != NULL ) {
fprintf( stderr, "%s: -D previously specified\n" ); fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
binddn = strdup( optarg ); binddn = strdup( optarg );
break; break;
case 'h': /* ldap host */ case 'h': /* ldap host */
if( ldapuri != NULL ) { if( ldapuri != NULL ) {
fprintf( stderr, "%s: -h incompatible with -H\n" ); fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldaphost != NULL ) { if( ldaphost != NULL ) {
fprintf( stderr, "%s: -h previously specified\n" ); fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldaphost = strdup( optarg ); ldaphost = strdup( optarg );
break; break;
case 'H': /* ldap URI */ case 'H': /* ldap URI */
if( ldaphost != NULL ) { if( ldaphost != NULL ) {
fprintf( stderr, "%s: -H incompatible with -h\n" ); fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldapport ) { if( ldapport ) {
fprintf( stderr, "%s: -H incompatible with -p\n" ); fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldapuri != NULL ) { if( ldapuri != NULL ) {
fprintf( stderr, "%s: -H previously specified\n" ); fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldapuri = strdup( optarg ); ldapuri = strdup( optarg );
@ -262,7 +262,7 @@ main( int argc, char *argv[] )
case 'O': case 'O':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) { if( sasl_secprops != NULL ) {
fprintf( stderr, "%s: -O previously specified\n" ); fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -286,7 +286,7 @@ main( int argc, char *argv[] )
break; break;
case 'p': case 'p':
if( ldapport ) { if( ldapport ) {
fprintf( stderr, "%s: -p previously specified\n" ); fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldapport = atoi( optarg ); ldapport = atoi( optarg );
@ -340,7 +340,7 @@ main( int argc, char *argv[] )
case 'R': case 'R':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) { if( sasl_realm != NULL ) {
fprintf( stderr, "%s: -R previously specified\n" ); fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -366,7 +366,7 @@ main( int argc, char *argv[] )
case 'U': case 'U':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) { if( sasl_authc_id != NULL ) {
fprintf( stderr, "%s: -U previously specified\n" ); fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -409,7 +409,7 @@ main( int argc, char *argv[] )
case 'Y': case 'Y':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) { if( sasl_mech != NULL ) {
fprintf( stderr, "%s: -Y previously specified\n" ); fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -441,7 +441,7 @@ main( int argc, char *argv[] )
case 'X': case 'X':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) { if( sasl_authz_id != NULL ) {
fprintf( stderr, "%s: -X previously specified\n" ); fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {

View file

@ -163,7 +163,7 @@ static int verbose, not, includeufn, vals2tmp, ldif;
int int
main( int argc, char **argv ) main( int argc, char **argv )
{ {
char *infile, *filtpattern, **attrs, line[BUFSIZ]; char *infile, *filtpattern, **attrs = NULL, line[BUFSIZ];
FILE *fp = NULL; FILE *fp = NULL;
int rc, i, first, scope, deref, attrsonly, manageDSAit; int rc, i, first, scope, deref, attrsonly, manageDSAit;
int referrals, timelimit, sizelimit, debug; int referrals, timelimit, sizelimit, debug;
@ -208,7 +208,7 @@ main( int argc, char **argv )
break; break;
case 'f': /* input file */ case 'f': /* input file */
if( infile != NULL ) { if( infile != NULL ) {
fprintf( stderr, "%s: -f previously specified\n" ); fprintf( stderr, "%s: -f previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
infile = strdup( optarg ); infile = strdup( optarg );
@ -261,33 +261,33 @@ main( int argc, char **argv )
break; break;
case 'D': /* bind DN */ case 'D': /* bind DN */
if( binddn != NULL ) { if( binddn != NULL ) {
fprintf( stderr, "%s: -D previously specified\n" ); fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
binddn = strdup( optarg ); binddn = strdup( optarg );
break; break;
case 'h': /* ldap host */ case 'h': /* ldap host */
if( ldapuri != NULL ) { if( ldapuri != NULL ) {
fprintf( stderr, "%s: -h incompatible with -H\n" ); fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldaphost != NULL ) { if( ldaphost != NULL ) {
fprintf( stderr, "%s: -h previously specified\n" ); fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldaphost = strdup( optarg ); ldaphost = strdup( optarg );
break; break;
case 'H': /* ldap URI */ case 'H': /* ldap URI */
if( ldaphost != NULL ) { if( ldaphost != NULL ) {
fprintf( stderr, "%s: -H incompatible with -h\n" ); fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldapport ) { if( ldapport ) {
fprintf( stderr, "%s: -H incompatible with -p\n" ); fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( ldapuri != NULL ) { if( ldapuri != NULL ) {
fprintf( stderr, "%s: -H previously specified\n" ); fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldapuri = strdup( optarg ); ldapuri = strdup( optarg );
@ -369,7 +369,7 @@ main( int argc, char **argv )
case 'O': case 'O':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) { if( sasl_secprops != NULL ) {
fprintf( stderr, "%s: -O previously specified\n" ); fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -393,7 +393,7 @@ main( int argc, char **argv )
break; break;
case 'p': case 'p':
if( ldapport ) { if( ldapport ) {
fprintf( stderr, "%s: -p previously specified\n" ); fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ldapport = atoi( optarg ); ldapport = atoi( optarg );
@ -447,7 +447,7 @@ main( int argc, char **argv )
case 'R': case 'R':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) { if( sasl_realm != NULL ) {
fprintf( stderr, "%s: -R previously specified\n" ); fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -473,7 +473,7 @@ main( int argc, char **argv )
case 'U': case 'U':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) { if( sasl_authc_id != NULL ) {
fprintf( stderr, "%s: -U previously specified\n" ); fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -516,7 +516,7 @@ main( int argc, char **argv )
case 'Y': case 'Y':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) { if( sasl_mech != NULL ) {
fprintf( stderr, "%s: -Y previously specified\n" ); fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -548,7 +548,7 @@ main( int argc, char **argv )
case 'X': case 'X':
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) { if( sasl_authz_id != NULL ) {
fprintf( stderr, "%s: -X previously specified\n" ); fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if( version == LDAP_VERSION2 ) { if( version == LDAP_VERSION2 ) {
@ -612,9 +612,7 @@ main( int argc, char **argv )
filtpattern = strdup( argv[optind++] ); filtpattern = strdup( argv[optind++] );
} }
if ( argv[optind] == NULL ) { if ( (argv[optind] != NULL) && (sortattr == NULL || *sortattr == '\0') ) {
attrs = NULL;
} else if ( sortattr == NULL || *sortattr == '\0' ) {
attrs = &argv[optind]; attrs = &argv[optind];
} }
@ -891,7 +889,7 @@ static int dosearch(
int sizelimit ) int sizelimit )
{ {
char filter[ BUFSIZ ]; char filter[ BUFSIZ ];
int rc, first; int rc;
int nresponses; int nresponses;
int nentries; int nentries;
int nreferences; int nreferences;
@ -1218,7 +1216,6 @@ static int print_result(
LDAP *ld, LDAP *ld,
LDAPMessage *result, int search ) LDAPMessage *result, int search )
{ {
char rst[BUFSIZ];
int rc; int rc;
int err; int err;
char *matcheddn = NULL; char *matcheddn = NULL;