]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/test.c
Don't copy and leak user; it's an env var so just use it directly.
[openldap] / libraries / libldap / test.c
index 404ffbfe29e0fb7146f63e36989d7bd431f55e19..77aca1e03602d455d2acb9aa59b06404b67a7543 100644 (file)
@@ -229,7 +229,10 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
 
 
 static int
-bind_prompt( LDAP *ld, LDAP_CONST char *url, int request, ber_int_t msgid)
+bind_prompt( LDAP *ld,
+       LDAP_CONST char *url,
+       ber_tag_t request, ber_int_t msgid,
+       void *params )
 {
        static char     dn[256], passwd[256];
        int     authmethod;
@@ -267,7 +270,7 @@ int
 main( int argc, char **argv )
 {
        LDAP            *ld = NULL;
-       int             i, c, port, cldapflg, errflg, method, id, msgtype;
+       int             i, c, port, errflg, method, id, msgtype;
        char            line[256], command1, command2, command3;
        char            passwd[64], dn[256], rdn[64], attr[64], value[256];
        char            filter[256], *host, **types;
@@ -284,18 +287,10 @@ main( int argc, char **argv )
        host = NULL;
        port = LDAP_PORT;
        dnsuffix = "";
-       cldapflg = errflg = 0;
+       errflg = 0;
 
-       while (( c = getopt( argc, argv, "uh:d:s:p:t:T:" )) != -1 ) {
+       while (( c = getopt( argc, argv, "h:d:s:p:t:T:" )) != -1 ) {
                switch( c ) {
-               case 'u':
-#ifdef LDAP_CONNECTIONLESS
-                       cldapflg++;
-#else /* LDAP_CONNECTIONLESS */
-                       printf( "Compile with -DLDAP_CONNECTIONLESS for UDP support\n" );
-#endif /* LDAP_CONNECTIONLESS */
-                       break;
-
                case 'd':
 #ifdef LDAP_DEBUG
                        ldap_debug = atoi( optarg );
@@ -346,20 +341,13 @@ main( int argc, char **argv )
                exit( EXIT_FAILURE );
        }
        
-       printf( "%s( %s, %d )\n",
-               cldapflg ? "cldap_open" : "ldap_init",
+       printf( "ldap_init( %s, %d )\n",
                host == NULL ? "(null)" : host, port );
 
-       if ( cldapflg ) {
-#ifdef LDAP_CONNECTIONLESS
-               ld = cldap_open( host, port );
-#endif /* LDAP_CONNECTIONLESS */
-       } else {
-               ld = ldap_init( host, port );
-       }
+       ld = ldap_init( host, port );
 
        if ( ld == NULL ) {
-               perror( cldapflg ? "cldap_open" : "ldap_init" );
+               perror( "ldap_init" );
                exit( EXIT_FAILURE );
        }
 
@@ -541,14 +529,7 @@ main( int argc, char **argv )
                        break;
 
                case 'q':       /* quit */
-#ifdef LDAP_CONNECTIONLESS
-                       if ( cldapflg )
-                               cldap_close( ld );
-#endif /* LDAP_CONNECTIONLESS */
-
-                       if ( !cldapflg ) {
-                               ldap_unbind( ld );
-                       }
+                       ldap_unbind( ld );
                        exit( EXIT_SUCCESS );
                        break;
 
@@ -607,28 +588,12 @@ main( int argc, char **argv )
                            "attrsonly (0=attrs&values, 1=attrs only)? " );
                        attrsonly = atoi( line );
 
-                       if ( cldapflg ) {
-#ifdef LDAP_CONNECTIONLESS
-                           getline( line, sizeof(line), stdin,
-                               "Requestor DN (for logging)? " );
-                           if ( cldap_search_s( ld, dn, scope, filter, types,
-                                   attrsonly, &res, line ) != 0 ) {
-                               ldap_perror( ld, "cldap_search_s" );
-                           } else {
-                               printf( "\nresult: msgid %d\n",
-                                   res->lm_msgid );
-                               handle_result( ld, res );
-                               res = NULL;
-                           }
-#endif /* LDAP_CONNECTIONLESS */
-                       } else {
                            if (( id = ldap_search( ld, dn, scope, filter,
                                    types, attrsonly  )) == -1 ) {
                                ldap_perror( ld, "ldap_search" );
                            } else {
                                printf( "Search initiated with id %d\n", id );
                            }
-                       }
                        free_list( types );
                        break;
 
@@ -637,37 +602,6 @@ main( int argc, char **argv )
                        timeout.tv_sec = atoi( line );
                        break;
 
-               case 'U':       /* set ufn search prefix */
-                       getline( line, sizeof(line), stdin, "ufn prefix? " );
-                       ldap_ufn_setprefix( ld, line );
-                       break;
-
-               case 'u':       /* user friendly search w/optional timeout */
-                       getline( dn, sizeof(dn), stdin, "ufn? " );
-                       strcat( dn, dnsuffix );
-                       types = get_list( "attrs to return? " );
-                       getline( line, sizeof(line), stdin,
-                           "attrsonly (0=attrs&values, 1=attrs only)? " );
-                       attrsonly = atoi( line );
-
-                       if ( command2 == 't' ) {
-                               id = ldap_ufn_search_c( ld, dn, types,
-                                   attrsonly, &res, ldap_ufn_timeout,
-                                   &timeout );
-                       } else {
-                               id = ldap_ufn_search_s( ld, dn, types,
-                                   attrsonly, &res );
-                       }
-                       if ( res == NULL )
-                               ldap_perror( ld, "ldap_ufn_search" );
-                       else {
-                               printf( "\nresult: err %d\n", id );
-                               handle_result( ld, res );
-                               res = NULL;
-                       }
-                       free_list( types );
-                       break;
-
                case 'l':       /* URL search */
                        getline( line, sizeof(line), stdin,
                            "attrsonly (0=attrs&values, 1=attrs only)? " );
@@ -770,7 +704,7 @@ main( int argc, char **argv )
                                getline( line, sizeof(line), stdin,
                                        "Prompt for bind credentials when chasing referrals (0=no, 1=yes)?" );
                                if ( atoi( line ) != 0 ) {
-                                       ldap_set_rebind_proc( ld, bind_prompt );
+                                       ldap_set_rebind_proc( ld, bind_prompt, NULL );
                                }
                        }
                        break;
@@ -803,12 +737,11 @@ main( int argc, char **argv )
     printf( "          [B]ind async  [c]ompare         [l]URL search\n" );
     printf( "          [modi]fy      [modr]dn          [rem]ove\n" );
     printf( "          [res]ult      [s]earch          [q]uit/unbind\n\n" );
-    printf( "          [u]fn search  [ut]fn search with timeout\n" );
     printf( "          [d]ebug       [e]nable cache    set ms[g]id\n" );
     printf( "          d[n]suffix    [t]imeout         [v]ersion\n" );
-    printf( "          [U]fn prefix  [x]uncache entry  [X]uncache request\n" );
     printf( "          [?]help       [o]ptions         [O]cache options\n" );
     printf( "          [E]xplode dn  [p]arse LDAP URL\n" );
+    printf( "          [x]uncache entry  [X]uncache request\n" );
                        break;
 
                default: