]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/test.c
More cleanup in ldap_pvt_tls_destroy()
[openldap] / libraries / libldap / test.c
index a64dfc6b45b17ea6867ea0f8a2eb22efda7a80f5..05e9cf90f86ba1b440ea4eec4b2ba269ae8550ec 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
 
 /* local functions */
 #ifndef HAVE_GETLINE
-static char *getline LDAP_P(( char *line, int len, FILE *fp, char *prompt ));
+static char *getline LDAP_P(( char *line, int len, FILE *fp, const char *prompt ));
 #endif
-static char **get_list LDAP_P(( char *prompt ));
-static int file_read LDAP_P(( char *path, struct berval *bv ));
-static LDAPMod **get_modlist LDAP_P(( char *prompt1, char *prompt2, char *prompt3 ));
+static char **get_list LDAP_P(( const char *prompt ));
+static int file_read LDAP_P(( const char *path, struct berval *bv ));
+static LDAPMod **get_modlist LDAP_P(( const char *prompt1,
+       const char *prompt2, const char *prompt3 ));
 static void handle_result LDAP_P(( LDAP *ld, LDAPMessage *lm ));
-static void print_ldap_result LDAP_P(( LDAP *ld, LDAPMessage *lm, char *s ));
+static void print_ldap_result LDAP_P(( LDAP *ld, LDAPMessage *lm,
+       const char *s ));
 static void print_search_entry LDAP_P(( LDAP *ld, LDAPMessage *res ));
 static void free_list LDAP_P(( char **list ));
 
@@ -51,7 +53,7 @@ static char *dnsuffix;
 
 #ifndef HAVE_GETLINE
 static char *
-getline( char *line, int len, FILE *fp, char *prompt )
+getline( char *line, int len, FILE *fp, const char *prompt )
 {
        printf(prompt);
 
@@ -65,7 +67,7 @@ getline( char *line, int len, FILE *fp, char *prompt )
 #endif
 
 static char **
-get_list( char *prompt )
+get_list( const char *prompt )
 {
        static char     buf[256];
        int             num;
@@ -111,7 +113,7 @@ free_list( char **list )
 
 
 static int
-file_read( char *path, struct berval *bv )
+file_read( const char *path, struct berval *bv )
 {
        FILE            *fp;
        ber_slen_t      rlen;
@@ -157,7 +159,10 @@ file_read( char *path, struct berval *bv )
 
 
 static LDAPMod **
-get_modlist( char *prompt1, char *prompt2, char *prompt3 )
+get_modlist(
+       const char *prompt1,
+       const char *prompt2,
+       const char *prompt3 )
 {
        static char     buf[256];
        int             num;
@@ -229,12 +234,15 @@ 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;
 
-       printf("rebind for request=%d msgid=%ld url=%s\n",
+       printf("rebind for request=%ld msgid=%ld url=%s\n",
                request, (long) msgid, url );
 
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
@@ -599,50 +607,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)? " );
-                       attrsonly = atoi( line );
-                       getline( line, sizeof(line), stdin, "LDAP URL? " );
-                       if (( id = ldap_url_search( ld, line, attrsonly  ))
-                               == -1 ) {
-                           ldap_perror( ld, "ldap_url_search" );
-                       } else {
-                           printf( "URL search initiated with id %d\n", id );
-                       }
-                       break;
-
                case 'p':       /* parse LDAP URL */
                        getline( line, sizeof(line), stdin, "LDAP URL? " );
                        if (( i = ldap_url_parse( line, &ludp )) != 0 ) {
@@ -732,7 +696,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;
@@ -762,15 +726,14 @@ main( int argc, char **argv )
 
                case '?':       /* help */
     printf( "Commands: [ad]d         [ab]andon         [b]ind\n" );
-    printf( "          [B]ind async  [c]ompare         [l]URL search\n" );
+    printf( "          [B]ind async  [c]ompare\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:
@@ -831,7 +794,7 @@ handle_result( LDAP *ld, LDAPMessage *lm )
 }
 
 static void
-print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s )
+print_ldap_result( LDAP *ld, LDAPMessage *lm, const char *s )
 {
        ldap_result2error( ld, lm, 1 );
        ldap_perror( ld, s );