]> git.sur5r.net Git - openldap/blobdiff - clients/ud/find.c
Fix format %x -> %lx in des_string_to_key
[openldap] / clients / ud / find.c
index 334ce9db907daf68d437788824eddee0dc72ade7..437c78fbff7b25f01719c91d28a4906960e982e1 100644 (file)
@@ -14,6 +14,8 @@
 
 #include <stdio.h>
 
+#include <ac/stdlib.h>
+
 #include <ac/ctype.h>
 #include <ac/string.h>
 #include <ac/time.h>
 
 #include "ud.h"
 
-extern char *search_base;      /* search base */
-extern int verbose;            /* verbose mode flag */
-extern LDAP *ld;               /* our ldap descriptor */
-       
 static int num_picked = 0;     /* used when user picks entry at More prompt */
 
-#ifdef DEBUG
-extern int debug;              /* debug flag */
-#endif
 
-vrfy(dn)
-char *dn;
+int
+vrfy( char *dn )
 {
        LDAPMessage *results;
        static char *attrs[2] = { "objectClass", NULL };
@@ -61,11 +56,8 @@ char *dn;
 }
        
 
-static LDAPMessage * disambiguate( result, matches, read_attrs, who )
-LDAPMessage *result;
-int matches;
-char **read_attrs;
-char *who;
+static LDAPMessage *
+disambiguate( LDAPMessage *result, int matches, char **read_attrs, char *who )
 {
        int choice;                     /* entry that user chooses */
        int i;
@@ -74,7 +66,6 @@ char *who;
        char *name = NULL;              /* DN to lookup */
        LDAPMessage *mp;
        int ld_errno = 0;
-       extern void Free();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -161,9 +152,8 @@ char *who;
        }
 }
 
-LDAPMessage * find(who, quiet)
-char *who;
-int quiet;
+LDAPMessage *
+find( char *who, int quiet )
 {
        register int i, j, k;           /* general ints */
        int matches;                    /* from ldap_count_entries() */
@@ -177,9 +167,6 @@ int quiet;
        char response[SMALL_BUF_SIZE];
        char *cp, *dn, **rdns;
        LDAPFiltInfo *fi;
-       extern LDAPFiltDesc *lfdp;              /* LDAP filter descriptor */
-       extern struct attribute attrlist[];     /* complete list of attrs */
-       extern void Free();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -235,7 +222,10 @@ int quiet;
                        ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
                        return(NULL);
                } else if (matches == 1) {
-                       if (ldap_search_s(ld, ldap_get_dn(ld, ldap_first_entry(ld, res)), LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res) != LDAP_SUCCESS) {
+                       dn = ldap_get_dn(ld, ldap_first_entry(ld, res));
+                       rc = ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res);
+                       ldap_memfree(dn);
+                       if (rc != LDAP_SUCCESS) {
                                int ld_errno = 0;
                                ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
                                if (ld_errno == LDAP_UNAVAILABLE)
@@ -247,8 +237,7 @@ int quiet;
                        ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
                        return(res);
                } else if (matches > 1 ) {
-                       return( disambiguate( ld, res, matches, read_attrs,
-                           who ) );
+                       return disambiguate( res, matches, read_attrs, who );
                }
                ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
        }
@@ -302,7 +291,10 @@ int quiet;
                                fflush(stdout);
                                fetch_buffer(response, sizeof(response), stdin);
                                if ((response[0] == 'n') || (response[0] == 'N'))
+                               {
+                                       ldap_memfree(dn);
                                        return(NULL);
+                               }
                        }
 #ifdef DEBUG
                        if (debug & D_FIND) {
@@ -321,9 +313,9 @@ int quiet;
                        if (ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res) != LDAP_SUCCESS) {
                                ldap_perror(ld, "ldap_search_s");
                                ldap_msgfree(res);
-                               return(NULL);
+                               res = NULL;
                        }
-                       Free(dn);
+                       ldap_memfree(dn);
                        return(res);
                }
                else if (matches > 0) {
@@ -337,8 +329,8 @@ int quiet;
        return(NULL);
 }
 
-pick_one(i)
-int i;
+int
+pick_one( int i )
 {
        int n;
        char user_pick[SMALL_BUF_SIZE];
@@ -363,13 +355,10 @@ int i;
        /* NOTREACHED */
 }
 
-print_list(list, names, matches)
-LDAPMessage *list;
-char *names[];
-int *matches;
+void
+print_list( LDAPMessage *list, char **names, int *matches )
 {
        char **rdns, **cpp;
-       extern int lpp;
        char resp[SMALL_BUF_SIZE];
        register LDAPMessage *ep;
        register int i = 1;
@@ -413,9 +402,8 @@ again:
        return;
 }
 
-find_all_subscribers(sub, group)
-char *sub[];
-char *group;
+int
+find_all_subscribers( char **sub, char *group )
 {
        int count;
        LDAPMessage *result;
@@ -460,9 +448,8 @@ char *group;
        return(count);
 }
 
-char * fetch_boolean_value(who, attr)
-char *who;
-struct attribute attr;
+char *
+fetch_boolean_value( char *who, struct attribute attr )
 {
        LDAPMessage *result;            /* from the search below */
        register LDAPMessage *ep;       /* entry pointer */