3 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/stdlib.h>
14 #include <ac/socket.h>
15 #include <ac/string.h>
17 #include <ac/unistd.h>
21 #ifdef HAVE_SYS_FILE_H
30 /* including the "internal" defs is legit and nec. since this test routine has
31 * a-priori knowledge of libldap internal workings.
32 * hodges@stanford.edu 5-Feb-96
38 static char *getline LDAP_P(( char *line, int len, FILE *fp, char *prompt ));
40 static char **get_list LDAP_P(( char *prompt ));
41 static int file_read LDAP_P(( char *path, struct berval *bv ));
42 static LDAPMod **get_modlist LDAP_P(( char *prompt1, char *prompt2, char *prompt3 ));
43 static void handle_result LDAP_P(( LDAP *ld, LDAPMessage *lm ));
44 static void print_ldap_result LDAP_P(( LDAP *ld, LDAPMessage *lm, char *s ));
45 static void print_search_entry LDAP_P(( LDAP *ld, LDAPMessage *res ));
46 static void free_list LDAP_P(( char **list ));
48 #define NOCACHEERRMSG "don't compile with -DLDAP_NOCACHE if you desire local caching"
50 static char *dnsuffix;
54 getline( char *line, int len, FILE *fp, char *prompt )
58 if ( fgets( line, len, fp ) == NULL )
61 line[ strlen( line ) - 1 ] = '\0';
68 get_list( char *prompt )
77 getline( buf, sizeof(buf), stdin, prompt );
82 if ( result == (char **) 0 )
83 result = (char **) malloc( sizeof(char *) );
85 result = (char **) realloc( result,
86 sizeof(char *) * (num + 1) );
88 result[num++] = (char *) strdup( buf );
90 if ( result == (char **) 0 )
92 result = (char **) realloc( result, sizeof(char *) * (num + 1) );
100 free_list( char **list )
104 if ( list != NULL ) {
105 for ( i = 0; list[ i ] != NULL; ++i ) {
108 free( (char *)list );
114 file_read( char *path, struct berval *bv )
120 if (( fp = fopen( path, "r" )) == NULL ) {
125 if ( fseek( fp, 0L, SEEK_END ) != 0 ) {
131 bv->bv_len = ftell( fp );
133 if (( bv->bv_val = (char *)malloc( bv->bv_len )) == NULL ) {
139 if ( fseek( fp, 0L, SEEK_SET ) != 0 ) {
145 rlen = fread( bv->bv_val, 1, bv->bv_len, fp );
149 if ( (ber_len_t) rlen != bv->bv_len ) {
155 return( bv->bv_len );
160 get_modlist( char *prompt1, char *prompt2, char *prompt3 )
162 static char buf[256];
166 struct berval **bvals;
172 getline( buf, sizeof(buf), stdin, prompt1 );
173 tmp.mod_op = atoi( buf );
175 if ( tmp.mod_op == -1 || buf[0] == '\0' )
179 getline( buf, sizeof(buf), stdin, prompt2 );
180 if ( buf[0] == '\0' )
182 tmp.mod_type = strdup( buf );
184 tmp.mod_values = get_list( prompt3 );
186 if ( tmp.mod_values != NULL ) {
189 for ( i = 0; tmp.mod_values[i] != NULL; ++i )
191 bvals = (struct berval **)calloc( i + 1,
192 sizeof( struct berval *));
193 for ( i = 0; tmp.mod_values[i] != NULL; ++i ) {
194 bvals[i] = (struct berval *)malloc(
195 sizeof( struct berval ));
196 if ( strncmp( tmp.mod_values[i], "{FILE}",
198 if ( file_read( tmp.mod_values[i] + 6,
203 bvals[i]->bv_val = tmp.mod_values[i];
205 strlen( tmp.mod_values[i] );
208 tmp.mod_bvalues = bvals;
209 tmp.mod_op |= LDAP_MOD_BVALUES;
212 if ( result == NULL )
213 result = (LDAPMod **) malloc( sizeof(LDAPMod *) );
215 result = (LDAPMod **) realloc( result,
216 sizeof(LDAPMod *) * (num + 1) );
218 result[num] = (LDAPMod *) malloc( sizeof(LDAPMod) );
219 *(result[num]) = tmp; /* struct copy */
222 if ( result == NULL )
224 result = (LDAPMod **) realloc( result, sizeof(LDAPMod *) * (num + 1) );
232 bind_prompt( LDAP *ld, LDAP_CONST char *url, int request, ber_int_t msgid)
234 static char dn[256], passwd[256];
237 printf("rebind for request=%d msgid=%ld url=%s\n",
238 request, (long) msgid, url );
240 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
241 getline( dn, sizeof(dn), stdin,
242 "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " );
243 if (( authmethod = atoi( dn )) == 3 ) {
244 authmethod = LDAP_AUTH_KRBV4;
248 #else /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
249 authmethod = LDAP_AUTH_SIMPLE;
250 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
252 getline( dn, sizeof(dn), stdin, "re-bind dn? " );
253 strcat( dn, dnsuffix );
255 if ( authmethod == LDAP_AUTH_SIMPLE && dn[0] != '\0' ) {
256 getline( passwd, sizeof(passwd), stdin,
257 "re-bind password? " );
262 return ldap_bind_s( ld, dn, passwd, authmethod);
267 main( int argc, char **argv )
270 int i, c, port, errflg, method, id, msgtype;
271 char line[256], command1, command2, command3;
272 char passwd[64], dn[256], rdn[64], attr[64], value[256];
273 char filter[256], *host, **types;
275 char *usage = "usage: %s [-u] [-h host] [-d level] [-s dnsuffix] [-p port] [-t file] [-T file]\n";
276 int bound, all, scope, attrsonly;
278 LDAPMod **mods, **attrs;
279 struct timeval timeout;
280 char *copyfname = NULL;
289 while (( c = getopt( argc, argv, "h:d:s:p:t:T:" )) != -1 ) {
293 ldap_debug = atoi( optarg );
295 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
296 ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &ldap_debug );
300 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
313 port = atoi( optarg );
316 case 't': /* copy ber's to given file */
317 copyfname = strdup( optarg );
318 /* copyoptions = LBER_TO_FILE; */
321 case 'T': /* only output ber's to given file */
322 copyfname = strdup( optarg );
323 /* copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY); */
331 if ( host == NULL && optind == argc - 1 ) {
332 host = argv[ optind ];
336 if ( errflg || optind < argc - 1 ) {
337 fprintf( stderr, usage, argv[ 0 ] );
338 exit( EXIT_FAILURE );
341 printf( "ldap_init( %s, %d )\n",
342 host == NULL ? "(null)" : host, port );
344 ld = ldap_init( host, port );
347 perror( "ldap_init" );
348 exit( EXIT_FAILURE );
351 if ( copyfname != NULL ) {
352 if ( ( ld->ld_sb->sb_fd = open( copyfname, O_WRONLY | O_CREAT,
355 exit ( EXIT_FAILURE );
357 ld->ld_sb->sb_options = copyoptions;
364 (void) memset( line, '\0', sizeof(line) );
365 while ( getline( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) {
370 switch ( command1 ) {
371 case 'a': /* add or abandon */
372 switch ( command2 ) {
374 getline( dn, sizeof(dn), stdin, "dn? " );
375 strcat( dn, dnsuffix );
376 if ( (attrs = get_modlist( NULL, "attr? ",
377 "value? " )) == NULL )
379 if ( (id = ldap_add( ld, dn, attrs )) == -1 )
380 ldap_perror( ld, "ldap_add" );
382 printf( "Add initiated with id %d\n",
386 case 'b': /* abandon */
387 getline( line, sizeof(line), stdin, "msgid? " );
389 if ( ldap_abandon( ld, id ) != 0 )
390 ldap_perror( ld, "ldap_abandon" );
392 printf( "Abandon successful\n" );
395 printf( "Possibilities: [ad]d, [ab]ort\n" );
399 case 'b': /* asynch bind */
400 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
401 getline( line, sizeof(line), stdin,
402 "method (0->simple, 1->krbv41, 2->krbv42)? " );
403 method = atoi( line ) | 0x80;
404 #else /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
405 method = LDAP_AUTH_SIMPLE;
406 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
407 getline( dn, sizeof(dn), stdin, "dn? " );
408 strcat( dn, dnsuffix );
410 if ( method == LDAP_AUTH_SIMPLE && dn[0] != '\0' )
411 getline( passwd, sizeof(passwd), stdin,
416 if ( ldap_bind( ld, dn, passwd, method ) == -1 ) {
417 fprintf( stderr, "ldap_bind failed\n" );
418 ldap_perror( ld, "ldap_bind" );
420 printf( "Bind initiated\n" );
425 case 'B': /* synch bind */
426 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
427 getline( line, sizeof(line), stdin,
428 "method 0->simple 1->krbv41 2->krbv42 3->krb? " );
429 method = atoi( line );
431 method = LDAP_AUTH_KRBV4;
433 method = method | 0x80;
434 #else /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
435 method = LDAP_AUTH_SIMPLE;
436 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
437 getline( dn, sizeof(dn), stdin, "dn? " );
438 strcat( dn, dnsuffix );
441 getline( passwd, sizeof(passwd), stdin,
446 if ( ldap_bind_s( ld, dn, passwd, method ) !=
448 fprintf( stderr, "ldap_bind_s failed\n" );
449 ldap_perror( ld, "ldap_bind_s" );
451 printf( "Bind successful\n" );
456 case 'c': /* compare */
457 getline( dn, sizeof(dn), stdin, "dn? " );
458 strcat( dn, dnsuffix );
459 getline( attr, sizeof(attr), stdin, "attr? " );
460 getline( value, sizeof(value), stdin, "value? " );
462 if ( (id = ldap_compare( ld, dn, attr, value )) == -1 )
463 ldap_perror( ld, "ldap_compare" );
465 printf( "Compare initiated with id %d\n", id );
468 case 'd': /* turn on debugging */
470 getline( line, sizeof(line), stdin, "debug level? " );
471 ldap_debug = atoi( line );
473 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
474 ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &ldap_debug );
478 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
482 case 'E': /* explode a dn */
483 getline( line, sizeof(line), stdin, "dn? " );
484 exdn = ldap_explode_dn( line, 0 );
485 for ( i = 0; exdn != NULL && exdn[i] != NULL; i++ ) {
486 printf( "\t%s\n", exdn[i] );
490 case 'g': /* set next msgid */
491 getline( line, sizeof(line), stdin, "msgid? " );
492 ld->ld_msgid = atoi( line );
495 case 'v': /* set version number */
496 getline( line, sizeof(line), stdin, "version? " );
497 ld->ld_version = atoi( line );
500 case 'm': /* modify or modifyrdn */
501 if ( strncmp( line, "modify", 4 ) == 0 ) {
502 getline( dn, sizeof(dn), stdin, "dn? " );
503 strcat( dn, dnsuffix );
504 if ( (mods = get_modlist(
505 "mod (0=>add, 1=>delete, 2=>replace -1=>done)? ",
506 "attribute type? ", "attribute value? " ))
509 if ( (id = ldap_modify( ld, dn, mods )) == -1 )
510 ldap_perror( ld, "ldap_modify" );
512 printf( "Modify initiated with id %d\n",
514 } else if ( strncmp( line, "modrdn", 4 ) == 0 ) {
515 getline( dn, sizeof(dn), stdin, "dn? " );
516 strcat( dn, dnsuffix );
517 getline( rdn, sizeof(rdn), stdin, "newrdn? " );
518 if ( (id = ldap_modrdn( ld, dn, rdn )) == -1 )
519 ldap_perror( ld, "ldap_modrdn" );
521 printf( "Modrdn initiated with id %d\n",
524 printf( "Possibilities: [modi]fy, [modr]dn\n" );
530 exit( EXIT_SUCCESS );
533 case 'r': /* result or remove */
534 switch ( command3 ) {
535 case 's': /* result */
536 getline( line, sizeof(line), stdin,
537 "msgid (-1=>any)? " );
538 if ( line[0] == '\0' )
542 getline( line, sizeof(line), stdin,
543 "all (0=>any, 1=>all)? " );
544 if ( line[0] == '\0' )
548 if (( msgtype = ldap_result( ld, id, all,
549 &timeout, &res )) < 1 ) {
550 ldap_perror( ld, "ldap_result" );
553 printf( "\nresult: msgtype %d msgid %d\n",
554 msgtype, res->lm_msgid );
555 handle_result( ld, res );
559 case 'm': /* remove */
560 getline( dn, sizeof(dn), stdin, "dn? " );
561 strcat( dn, dnsuffix );
562 if ( (id = ldap_delete( ld, dn )) == -1 )
563 ldap_perror( ld, "ldap_delete" );
565 printf( "Remove initiated with id %d\n",
570 printf( "Possibilities: [rem]ove, [res]ult\n" );
575 case 's': /* search */
576 getline( dn, sizeof(dn), stdin, "searchbase? " );
577 strcat( dn, dnsuffix );
578 getline( line, sizeof(line), stdin,
579 "scope (0=Base, 1=One Level, 2=Subtree)? " );
580 scope = atoi( line );
581 getline( filter, sizeof(filter), stdin,
582 "search filter (e.g. sn=jones)? " );
583 types = get_list( "attrs to return? " );
584 getline( line, sizeof(line), stdin,
585 "attrsonly (0=attrs&values, 1=attrs only)? " );
586 attrsonly = atoi( line );
588 if (( id = ldap_search( ld, dn, scope, filter,
589 types, attrsonly )) == -1 ) {
590 ldap_perror( ld, "ldap_search" );
592 printf( "Search initiated with id %d\n", id );
597 case 't': /* set timeout value */
598 getline( line, sizeof(line), stdin, "timeout? " );
599 timeout.tv_sec = atoi( line );
603 case 'U': /* set ufn search prefix */
604 getline( line, sizeof(line), stdin, "ufn prefix? " );
605 ldap_ufn_setprefix( ld, line );
608 case 'u': /* user friendly search w/optional timeout */
609 getline( dn, sizeof(dn), stdin, "ufn? " );
610 strcat( dn, dnsuffix );
611 types = get_list( "attrs to return? " );
612 getline( line, sizeof(line), stdin,
613 "attrsonly (0=attrs&values, 1=attrs only)? " );
614 attrsonly = atoi( line );
616 if ( command2 == 't' ) {
617 id = ldap_ufn_search_c( ld, dn, types,
618 attrsonly, &res, ldap_ufn_timeout,
621 id = ldap_ufn_search_s( ld, dn, types,
625 ldap_perror( ld, "ldap_ufn_search" );
627 printf( "\nresult: err %d\n", id );
628 handle_result( ld, res );
635 case 'l': /* URL search */
636 getline( line, sizeof(line), stdin,
637 "attrsonly (0=attrs&values, 1=attrs only)? " );
638 attrsonly = atoi( line );
639 getline( line, sizeof(line), stdin, "LDAP URL? " );
640 if (( id = ldap_url_search( ld, line, attrsonly ))
642 ldap_perror( ld, "ldap_url_search" );
644 printf( "URL search initiated with id %d\n", id );
648 case 'p': /* parse LDAP URL */
649 getline( line, sizeof(line), stdin, "LDAP URL? " );
650 if (( i = ldap_url_parse( line, &ludp )) != 0 ) {
651 fprintf( stderr, "ldap_url_parse: error %d\n", i );
653 printf( "\t host: " );
654 if ( ludp->lud_host == NULL ) {
655 printf( "DEFAULT\n" );
657 printf( "<%s>\n", ludp->lud_host );
659 printf( "\t port: " );
660 if ( ludp->lud_port == 0 ) {
661 printf( "DEFAULT\n" );
663 printf( "%d\n", ludp->lud_port );
665 printf( "\t dn: <%s>\n", ludp->lud_dn );
666 printf( "\t attrs:" );
667 if ( ludp->lud_attrs == NULL ) {
670 for ( i = 0; ludp->lud_attrs[ i ] != NULL; ++i ) {
671 printf( " <%s>", ludp->lud_attrs[ i ] );
674 printf( "\n\t scope: %s\n", ludp->lud_scope == LDAP_SCOPE_ONELEVEL ?
675 "ONE" : ludp->lud_scope == LDAP_SCOPE_BASE ? "BASE" :
676 ludp->lud_scope == LDAP_SCOPE_SUBTREE ? "SUB" : "**invalid**" );
677 printf( "\tfilter: <%s>\n", ludp->lud_filter );
678 ldap_free_urldesc( ludp );
682 case 'n': /* set dn suffix, for convenience */
683 getline( line, sizeof(line), stdin, "DN suffix? " );
684 strcpy( dnsuffix, line );
687 case 'e': /* enable cache */
689 printf( NOCACHEERRMSG );
690 #else /* LDAP_NOCACHE */
691 getline( line, sizeof(line), stdin, "Cache timeout (secs)? " );
693 getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " );
694 if ( ldap_enable_cache( ld, i, atoi( line )) == 0 ) {
695 printf( "local cache is on\n" );
697 printf( "ldap_enable_cache failed\n" );
699 #endif /* LDAP_NOCACHE */
702 case 'x': /* uncache entry */
704 printf( NOCACHEERRMSG );
705 #else /* LDAP_NOCACHE */
706 getline( line, sizeof(line), stdin, "DN? " );
707 ldap_uncache_entry( ld, line );
708 #endif /* LDAP_NOCACHE */
711 case 'X': /* uncache request */
713 printf( NOCACHEERRMSG );
714 #else /* LDAP_NOCACHE */
715 getline( line, sizeof(line), stdin, "request msgid? " );
716 ldap_uncache_request( ld, atoi( line ));
717 #endif /* LDAP_NOCACHE */
720 case 'o': /* set ldap options */
721 getline( line, sizeof(line), stdin, "alias deref (0=never, 1=searching, 2=finding, 3=always)?" );
722 ld->ld_deref = atoi( line );
723 getline( line, sizeof(line), stdin, "timelimit?" );
724 ld->ld_timelimit = atoi( line );
725 getline( line, sizeof(line), stdin, "sizelimit?" );
726 ld->ld_sizelimit = atoi( line );
728 LDAP_BOOL_ZERO(&ld->ld_options);
730 getline( line, sizeof(line), stdin,
731 "Recognize and chase referrals (0=no, 1=yes)?" );
732 if ( atoi( line ) != 0 ) {
733 LDAP_BOOL_SET(&ld->ld_options, LDAP_BOOL_REFERRALS);
734 getline( line, sizeof(line), stdin,
735 "Prompt for bind credentials when chasing referrals (0=no, 1=yes)?" );
736 if ( atoi( line ) != 0 ) {
737 ldap_set_rebind_proc( ld, bind_prompt );
742 case 'O': /* set cache options */
744 printf( NOCACHEERRMSG );
745 #else /* LDAP_NOCACHE */
746 getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" );
747 switch( atoi( line )) {
749 ldap_set_cache_options( ld, 0 );
752 ldap_set_cache_options( ld,
753 LDAP_CACHE_OPT_CACHENOERRS );
756 ldap_set_cache_options( ld,
757 LDAP_CACHE_OPT_CACHEALLERRS );
760 printf( "not a valid cache option\n" );
762 #endif /* LDAP_NOCACHE */
766 printf( "Commands: [ad]d [ab]andon [b]ind\n" );
767 printf( " [B]ind async [c]ompare [l]URL search\n" );
768 printf( " [modi]fy [modr]dn [rem]ove\n" );
769 printf( " [res]ult [s]earch [q]uit/unbind\n\n" );
771 printf( " [u]fn search [ut]fn search with timeout [U]fn prefix\n" );
773 printf( " [d]ebug [e]nable cache set ms[g]id\n" );
774 printf( " d[n]suffix [t]imeout [v]ersion\n" );
775 printf( " [?]help [o]ptions [O]cache options\n" );
776 printf( " [E]xplode dn [p]arse LDAP URL\n" );
777 printf( " [x]uncache entry [X]uncache request\n" );
781 printf( "Invalid command. Type ? for help.\n" );
785 (void) memset( line, '\0', sizeof(line) );
792 handle_result( LDAP *ld, LDAPMessage *lm )
794 switch ( lm->lm_msgtype ) {
795 case LDAP_RES_COMPARE:
796 printf( "Compare result\n" );
797 print_ldap_result( ld, lm, "compare" );
800 case LDAP_RES_SEARCH_RESULT:
801 printf( "Search result\n" );
802 print_ldap_result( ld, lm, "search" );
805 case LDAP_RES_SEARCH_ENTRY:
806 printf( "Search entry\n" );
807 print_search_entry( ld, lm );
811 printf( "Add result\n" );
812 print_ldap_result( ld, lm, "add" );
815 case LDAP_RES_DELETE:
816 printf( "Delete result\n" );
817 print_ldap_result( ld, lm, "delete" );
820 case LDAP_RES_MODRDN:
821 printf( "ModRDN result\n" );
822 print_ldap_result( ld, lm, "modrdn" );
826 printf( "Bind result\n" );
827 print_ldap_result( ld, lm, "bind" );
831 printf( "Unknown result type 0x%lx\n",
832 (unsigned long) lm->lm_msgtype );
833 print_ldap_result( ld, lm, "unknown" );
838 print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s )
840 ldap_result2error( ld, lm, 1 );
841 ldap_perror( ld, s );
843 if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
844 fprintf( stderr, "Additional info: %s\n", ld->ld_error );
845 if ( LDAP_NAME_ERROR( ld->ld_errno ) && ld->ld_matched != NULL )
846 fprintf( stderr, "Matched DN: %s\n", ld->ld_matched );
851 print_search_entry( LDAP *ld, LDAPMessage *res )
855 for ( e = ldap_first_entry( ld, res ); e != NULL;
856 e = ldap_next_entry( ld, e ) )
858 BerElement *ber = NULL;
861 if ( e->lm_msgtype == LDAP_RES_SEARCH_RESULT )
864 dn = ldap_get_dn( ld, e );
865 printf( "\tDN: %s\n", dn );
867 ufn = ldap_dn2ufn( dn );
868 printf( "\tUFN: %s\n", ufn );
873 for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
874 a = ldap_next_attribute( ld, e, ber ) )
876 struct berval **vals;
878 printf( "\t\tATTR: %s\n", a );
879 if ( (vals = ldap_get_values_len( ld, e, a ))
881 printf( "\t\t\t(no values)\n" );
884 for ( i = 0; vals[i] != NULL; i++ ) {
888 for ( j = 0; (ber_len_t) j < vals[i]->bv_len; j++ )
889 if ( !isascii( vals[i]->bv_val[j] ) ) {
895 printf( "\t\t\tlength (%ld) (not ascii)\n", vals[i]->bv_len );
896 #ifdef BPRINT_NONASCII
897 ber_bprint( vals[i]->bv_val,
899 #endif /* BPRINT_NONASCII */
902 printf( "\t\t\tlength (%ld) %s\n",
903 vals[i]->bv_len, vals[i]->bv_val );
905 ber_bvecfree( vals );
914 if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT
915 || res->lm_chain != NULL )
916 print_ldap_result( ld, res, "search" );