break;
case 'f': /* read DNs from a file */
if( fp != NULL ) {
- fprintf( stderr, "%s: -f previously specified\n" );
+ fprintf( stderr, "%s: -f previously specified\n", prog );
return EXIT_FAILURE;
}
if (( fp = fopen( optarg, "r" )) == NULL ) {
break;
case 'D': /* bind DN */
if( binddn != NULL ) {
- fprintf( stderr, "%s: -D previously specified\n" );
+ fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE;
}
binddn = strdup( optarg );
break;
case 'h': /* ldap host */
if( ldapuri != NULL ) {
- fprintf( stderr, "%s: -h incompatible with -H\n" );
+ fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE;
}
if( ldaphost != NULL ) {
- fprintf( stderr, "%s: -h previously specified\n" );
+ fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE;
}
ldaphost = strdup( optarg );
break;
case 'H': /* ldap URI */
if( ldaphost != NULL ) {
- fprintf( stderr, "%s: -H incompatible with -h\n" );
+ fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE;
}
if( ldapport ) {
- fprintf( stderr, "%s: -H incompatible with -p\n" );
+ fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE;
}
if( ldapuri != NULL ) {
- fprintf( stderr, "%s: -H previously specified\n" );
+ fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE;
}
ldapuri = strdup( optarg );
case 'O':
#ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) {
- fprintf( stderr, "%s: -O previously specified\n" );
+ fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
break;
case 'p':
if( ldapport ) {
- fprintf( stderr, "%s: -p previously specified\n" );
+ fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE;
}
ldapport = atoi( optarg );
case 'R':
#ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) {
- fprintf( stderr, "%s: -R previously specified\n" );
+ fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'U':
#ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) {
- fprintf( stderr, "%s: -U previously specified\n" );
+ fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'Y':
#ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) {
- fprintf( stderr, "%s: -Y previously specified\n" );
+ fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'X':
#ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) {
- fprintf( stderr, "%s: -X previously specified\n" );
+ fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
break;
case 'f': /* read from file */
if( infile != NULL ) {
- fprintf( stderr, "%s: -f previously specified\n" );
+ fprintf( stderr, "%s: -f previously specified\n", prog );
return EXIT_FAILURE;
}
infile = strdup( optarg );
break;
case 'D': /* bind DN */
if( binddn != NULL ) {
- fprintf( stderr, "%s: -D previously specified\n" );
+ fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE;
}
binddn = strdup( optarg );
break;
case 'h': /* ldap host */
if( ldapuri != NULL ) {
- fprintf( stderr, "%s: -h incompatible with -H\n" );
+ fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE;
}
if( ldaphost != NULL ) {
- fprintf( stderr, "%s: -h previously specified\n" );
+ fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE;
}
ldaphost = strdup( optarg );
break;
case 'H': /* ldap URI */
if( ldaphost != NULL ) {
- fprintf( stderr, "%s: -H incompatible with -h\n" );
+ fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE;
}
if( ldapport ) {
- fprintf( stderr, "%s: -H incompatible with -p\n" );
+ fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE;
}
if( ldapuri != NULL ) {
- fprintf( stderr, "%s: -H previously specified\n" );
+ fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE;
}
ldapuri = strdup( optarg );
case 'O':
#ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) {
- fprintf( stderr, "%s: -O previously specified\n" );
+ fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
break;
case 'p':
if( ldapport ) {
- fprintf( stderr, "%s: -p previously specified\n" );
+ fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE;
}
ldapport = atoi( optarg );
case 'R':
#ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) {
- fprintf( stderr, "%s: -R previously specified\n" );
+ fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'U':
#ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) {
- fprintf( stderr, "%s: -U previously specified\n" );
+ fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'Y':
#ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) {
- fprintf( stderr, "%s: -Y previously specified\n" );
+ fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'X':
#ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) {
- fprintf( stderr, "%s: -X previously specified\n" );
+ fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
break;
case 'f': /* read from file */
if( infile != NULL ) {
- fprintf( stderr, "%s: -f previously specified\n" );
+ fprintf( stderr, "%s: -f previously specified\n", prog );
return EXIT_FAILURE;
}
infile = strdup( optarg );
break;
case 'D': /* bind DN */
if( binddn != NULL ) {
- fprintf( stderr, "%s: -D previously specified\n" );
+ fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE;
}
binddn = strdup( optarg );
break;
case 'h': /* ldap host */
if( ldapuri != NULL ) {
- fprintf( stderr, "%s: -h incompatible with -H\n" );
+ fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE;
}
if( ldaphost != NULL ) {
- fprintf( stderr, "%s: -h previously specified\n" );
+ fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE;
}
ldaphost = strdup( optarg );
break;
case 'H': /* ldap URI */
if( ldaphost != NULL ) {
- fprintf( stderr, "%s: -H incompatible with -h\n" );
+ fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE;
}
if( ldapport ) {
- fprintf( stderr, "%s: -H incompatible with -p\n" );
+ fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE;
}
if( ldapuri != NULL ) {
- fprintf( stderr, "%s: -H previously specified\n" );
+ fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE;
}
ldapuri = strdup( optarg );
case 'O':
#ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) {
- fprintf( stderr, "%s: -O previously specified\n" );
+ fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
break;
case 'p':
if( ldapport ) {
- fprintf( stderr, "%s: -p previously specified\n" );
+ fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE;
}
ldapport = atoi( optarg );
case 'R':
#ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) {
- fprintf( stderr, "%s: -R previously specified\n" );
+ fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'U':
#ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) {
- fprintf( stderr, "%s: -U previously specified\n" );
+ fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'Y':
#ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) {
- fprintf( stderr, "%s: -Y previously specified\n" );
+ fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'X':
#ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) {
- fprintf( stderr, "%s: -X previously specified\n" );
+ fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
break;
case 'D': /* bind DN */
if( binddn != NULL ) {
- fprintf( stderr, "%s: -D previously specified\n" );
+ fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE;
}
binddn = strdup( optarg );
break;
case 'h': /* ldap host */
if( ldapuri != NULL ) {
- fprintf( stderr, "%s: -h incompatible with -H\n" );
+ fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE;
}
if( ldaphost != NULL ) {
- fprintf( stderr, "%s: -h previously specified\n" );
+ fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE;
}
ldaphost = strdup( optarg );
break;
case 'H': /* ldap URI */
if( ldaphost != NULL ) {
- fprintf( stderr, "%s: -H incompatible with -h\n" );
+ fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE;
}
if( ldapport ) {
- fprintf( stderr, "%s: -H incompatible with -p\n" );
+ fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE;
}
if( ldapuri != NULL ) {
- fprintf( stderr, "%s: -H previously specified\n" );
+ fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE;
}
ldapuri = strdup( optarg );
case 'O':
#ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) {
- fprintf( stderr, "%s: -O previously specified\n" );
+ fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
break;
case 'p':
if( ldapport ) {
- fprintf( stderr, "%s: -p previously specified\n" );
+ fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE;
}
ldapport = atoi( optarg );
case 'R':
#ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) {
- fprintf( stderr, "%s: -R previously specified\n" );
+ fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'U':
#ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) {
- fprintf( stderr, "%s: -U previously specified\n" );
+ fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'Y':
#ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) {
- fprintf( stderr, "%s: -Y previously specified\n" );
+ fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'X':
#ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) {
- fprintf( stderr, "%s: -X previously specified\n" );
+ fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
int
main( int argc, char **argv )
{
- char *infile, *filtpattern, **attrs, line[BUFSIZ];
+ char *infile, *filtpattern, **attrs = NULL, line[BUFSIZ];
FILE *fp = NULL;
int rc, i, first, scope, deref, attrsonly, manageDSAit;
int referrals, timelimit, sizelimit, debug;
break;
case 'f': /* input file */
if( infile != NULL ) {
- fprintf( stderr, "%s: -f previously specified\n" );
+ fprintf( stderr, "%s: -f previously specified\n", prog );
return EXIT_FAILURE;
}
infile = strdup( optarg );
break;
case 'D': /* bind DN */
if( binddn != NULL ) {
- fprintf( stderr, "%s: -D previously specified\n" );
+ fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE;
}
binddn = strdup( optarg );
break;
case 'h': /* ldap host */
if( ldapuri != NULL ) {
- fprintf( stderr, "%s: -h incompatible with -H\n" );
+ fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE;
}
if( ldaphost != NULL ) {
- fprintf( stderr, "%s: -h previously specified\n" );
+ fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE;
}
ldaphost = strdup( optarg );
break;
case 'H': /* ldap URI */
if( ldaphost != NULL ) {
- fprintf( stderr, "%s: -H incompatible with -h\n" );
+ fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE;
}
if( ldapport ) {
- fprintf( stderr, "%s: -H incompatible with -p\n" );
+ fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE;
}
if( ldapuri != NULL ) {
- fprintf( stderr, "%s: -H previously specified\n" );
+ fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE;
}
ldapuri = strdup( optarg );
case 'O':
#ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) {
- fprintf( stderr, "%s: -O previously specified\n" );
+ fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
break;
case 'p':
if( ldapport ) {
- fprintf( stderr, "%s: -p previously specified\n" );
+ fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE;
}
ldapport = atoi( optarg );
case 'R':
#ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) {
- fprintf( stderr, "%s: -R previously specified\n" );
+ fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'U':
#ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) {
- fprintf( stderr, "%s: -U previously specified\n" );
+ fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'Y':
#ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) {
- fprintf( stderr, "%s: -Y previously specified\n" );
+ fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
case 'X':
#ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) {
- fprintf( stderr, "%s: -X previously specified\n" );
+ fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
filtpattern = strdup( argv[optind++] );
}
- if ( argv[optind] == NULL ) {
- attrs = NULL;
- } else if ( sortattr == NULL || *sortattr == '\0' ) {
+ if ( (argv[optind] != NULL) && (sortattr == NULL || *sortattr == '\0') ) {
attrs = &argv[optind];
}
int sizelimit )
{
char filter[ BUFSIZ ];
- int rc, first;
+ int rc;
int nresponses;
int nentries;
int nreferences;
LDAP *ld,
LDAPMessage *result, int search )
{
- char rst[BUFSIZ];
int rc;
int err;
char *matcheddn = NULL;