From: Kurt Zeilenga Date: Sun, 6 Apr 2003 02:59:15 +0000 (+0000) Subject: Mark translatable strings. Needs work. X-Git-Tag: AUTOCONF_2_57~50 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0dcd32372c5e76e6173b8b798da99f043bb3100c;p=openldap Mark translatable strings. Needs work. --- diff --git a/clients/tools/common.c b/clients/tools/common.c index 526358d8f6..d65d13bcab 100644 --- a/clients/tools/common.c +++ b/clients/tools/common.c @@ -56,49 +56,57 @@ int version = 0; /* Set in main() */ char *prog = NULL; +void +tool_init( void ) +{ + setlocale(LC_MESSAGES,""); + bindtextdomain(OPENLDAP_PACKAGE, LDAP_LOCALEDIR); + textdomain(OPENLDAP_PACKAGE); +} + void tool_common_usage( void ) { static const char *const descriptions[] = { -" -c continuous operation mode (do not stop on errors)\n", -" -C chase referrals\n", -" -d level set LDAP debugging level to `level'\n", -" -D binddn bind DN\n", -" -e [!][=] general controls (! indicates criticality)\n" -" [!]authzid= (\"dn:\" or \"u:\")\n" -" [!]manageDSAit (alternate form, see -M)\n" -" [!]noop\n", -" -f file read operations from `file'\n", -" -h host LDAP server\n", -" -H URI LDAP Uniform Resource Indentifier(s)\n", -" -I use SASL Interactive mode\n", -" -k use Kerberos authentication\n", -" -K like -k, but do only step 1 of the Kerberos bind\n", -" -M enable Manage DSA IT control (-MM to make critical)\n", -" -n show what would be done but don't actually do it\n", -" -O props SASL security properties\n", -" -p port port on LDAP server\n", -" -P version procotol version (default: 3)\n", -" -Q use SASL Quiet mode\n", -" -R realm SASL realm\n", -" -U authcid SASL authentication identity\n", -" -v run in verbose mode (diagnostics to standard output)\n", -" -V print version info (-VV only)\n", -" -w passwd bind password (for simple authentication)\n", -" -W prompt for bind password\n", -" -x Simple authentication\n", -" -X authzid SASL authorization identity (\"dn:\" or \"u:\")\n", -" -y file Read password from file\n", -" -Y mech SASL mechanism\n", -" -Z Start TLS request (-ZZ to require successful response)\n", +N_(" -c continuous operation mode (do not stop on errors)\n"), +N_(" -C chase referrals\n"), +N_(" -d level set LDAP debugging level to `level'\n"), +N_(" -D binddn bind DN\n"), +N_(" -e [!][=] general controls (! indicates criticality)\n") +N_(" [!]authzid= (\"dn:\" or \"u:\")\n") +N_(" [!]manageDSAit (alternate form, see -M)\n") +N_(" [!]noop\n"), +N_(" -f file read operations from `file'\n"), +N_(" -h host LDAP server\n"), +N_(" -H URI LDAP Uniform Resource Indentifier(s)\n"), +N_(" -I use SASL Interactive mode\n"), +N_(" -k use Kerberos authentication\n"), +N_(" -K like -k, but do only step 1 of the Kerberos bind\n"), +N_(" -M enable Manage DSA IT control (-MM to make critical)\n"), +N_(" -n show what would be done but don't actually do it\n"), +N_(" -O props SASL security properties\n"), +N_(" -p port port on LDAP server\n"), +N_(" -P version procotol version (default: 3)\n"), +N_(" -Q use SASL Quiet mode\n"), +N_(" -R realm SASL realm\n"), +N_(" -U authcid SASL authentication identity\n"), +N_(" -v run in verbose mode (diagnostics to standard output)\n"), +N_(" -V print version info (-VV only)\n"), +N_(" -w passwd bind password (for simple authentication)\n"), +N_(" -W prompt for bind password\n"), +N_(" -x Simple authentication\n"), +N_(" -X authzid SASL authorization identity (\"dn:\" or \"u:\")\n"), +N_(" -y file Read password from file\n"), +N_(" -Y mech SASL mechanism\n"), +N_(" -Z Start TLS request (-ZZ to require successful response)\n"), NULL }; const char *const *cpp; - fputs( "Common options:\n", stderr ); + fputs( _("Common options:\n"), stderr ); for( cpp = descriptions; *cpp != NULL; cpp++ ) { if( strchr( options, (*cpp)[3] ) ) { - fputs( *cpp, stderr ); + fputs( _(*cpp), stderr ); } } } diff --git a/clients/tools/common.h b/clients/tools/common.h index 2791dbe2fb..dabcf250c9 100644 --- a/clients/tools/common.h +++ b/clients/tools/common.h @@ -52,6 +52,7 @@ void usage LDAP_P(( void )) LDAP_GCCATTR((noreturn)); int handle_private_option LDAP_P(( int i )); /* Defined in common.c */ +void tool_init LDAP_P(( void )); void tool_common_usage LDAP_P(( void )); void tool_args LDAP_P(( int, char ** )); LDAP *tool_conn_setup LDAP_P(( int dont, void (*private_setup)( LDAP * ) )); diff --git a/clients/tools/ldapcompare.c b/clients/tools/ldapcompare.c index ec865bf845..18b1ae3877 100644 --- a/clients/tools/ldapcompare.c +++ b/clients/tools/ldapcompare.c @@ -41,17 +41,15 @@ static int quiet = 0; void usage( void ) { - fprintf( stderr, -"usage: %s [options] DN \n" -"where:\n" -" DN\tDistinguished Name\n" -" attr\tassertion attribute\n" -" value\tassertion value\n" -" b64value\tbase64 encoding of assertion value\n" - -"Compare options:\n" -" -z Quiet mode, don't print anything, use return values\n" - , prog ); + fprintf( stderr, _("usage: %s [options] DN \n"), prog); + fprintf( stderr, _("where:\n")); + fprintf( stderr, _(" DN\tDistinguished Name\n")); + fprintf( stderr, _(" attr\tassertion attribute\n")); + fprintf( stderr, _(" value\tassertion value\n")); + fprintf( stderr, _(" b64value\tbase64 encoding of assertion value\n")); + + fprintf( stderr, _("Compare options:\n")); + fprintf( stderr, _(" -z Quiet mode, don't print anything, use return values\n")); tool_common_usage(); exit( EXIT_FAILURE ); } @@ -78,7 +76,7 @@ handle_private_option( int i ) int crit; case 'E': /* compare controls */ if( protocol == LDAP_VERSION2 ) { - fprintf( stderr, "%s: -E incompatible with LDAPv%d\n", + fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"), prog, protocol ); exit( EXIT_FAILURE ); } @@ -98,7 +96,7 @@ handle_private_option( int i ) if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } - fprintf( stderr, "Invalid compare control name: %s\n", control ); + fprintf( stderr, _("Invalid compare control name: %s\n"), control ); usage(); #endif @@ -122,6 +120,7 @@ main( int argc, char **argv ) LDAP *ld = NULL; struct berval bvalue = { 0, NULL }; + tool_init(); prog = lutil_progname( "ldapcompare", argc, argv ); tool_args( argc, argv ); @@ -153,7 +152,7 @@ main( int argc, char **argv ) bvalue.bv_val, strlen( &sep[1] )); if (bvalue.bv_len == (ber_len_t)-1) { - fprintf(stderr, "base64 decode error\n"); + fprintf(stderr, _("base64 decode error\n")); exit(-1); } } @@ -165,7 +164,7 @@ main( int argc, char **argv ) rc = lutil_get_filed_password( pw_file, &passwd ); if( rc ) return EXIT_FAILURE; } else { - passwd.bv_val = getpassphrase( "Enter LDAP Password: " ); + passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") ); passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0; } } @@ -176,7 +175,7 @@ main( int argc, char **argv ) tool_server_controls( ld, NULL, 0 ); if ( verbose ) { - fprintf( stderr, "DN:%s, attr:%s, value:%s\n", + fprintf( stderr, _("DN:%s, attr:%s, value:%s\n"), compdn, attrs, sep ); } @@ -217,10 +216,10 @@ static int docompare( if ( !quiet ) { if ( rc == LDAP_COMPARE_TRUE ) { rc = 0; - printf("TRUE\n"); + printf(_("TRUE\n")); } else if ( rc == LDAP_COMPARE_FALSE ) { rc = 0; - printf("FALSE\n"); + printf(_("FALSE\n")); } else { ldap_perror( ld, "ldap_compare" ); } diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index d3638404a5..908f7f1495 100644 --- a/clients/tools/ldapdelete.c +++ b/clients/tools/ldapdelete.c @@ -36,14 +36,12 @@ static int deletechildren LDAP_P(( void usage( void ) { - fprintf( stderr, -"Delete entries from an LDAP server\n\n" -"usage: %s [options] [dn]...\n" -" dn: list of DNs to delete. If not given, it will be readed from stdin\n" -" or from the file specified with \"-f file\".\n" -"Delete Options:\n" -" -r delete recursively\n" - , prog ); + fprintf( stderr, _("Delete entries from an LDAP server\n\n")); + fprintf( stderr, _("usage: %s [options] [dn]...\n"), prog); + fprintf( stderr, _(" dn: list of DNs to delete. If not given, it will be readed from stdin\n")); + fprintf( stderr, _(" or from the file specified with \"-f file\".\n")); + fprintf( stderr, _("Delete Options:\n")); + fprintf( stderr, _(" -r delete recursively\n")); tool_common_usage(); exit( EXIT_FAILURE ); } @@ -61,7 +59,7 @@ handle_private_option( int i ) char *control, *cvalue; case 'E': /* delete controls */ if( protocol == LDAP_VERSION2 ) { - fprintf( stderr, "%s: -E incompatible with LDAPv%d\n", + fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"), prog, protocol ); exit( EXIT_FAILURE ); } @@ -81,7 +79,7 @@ handle_private_option( int i ) if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } - fprintf( stderr, "Invalid delete control name: %s\n", control ); + fprintf( stderr, _("Invalid delete control name: %s\n"), control ); usage(); #endif @@ -115,6 +113,7 @@ main( int argc, char **argv ) fp = NULL; + tool_init(); prog = lutil_progname( "ldapdelete", argc, argv ); tool_args( argc, argv ); @@ -137,7 +136,7 @@ main( int argc, char **argv ) rc = lutil_get_filed_password( pw_file, &passwd ); if( rc ) return EXIT_FAILURE; } else { - passwd.bv_val = getpassphrase( "Enter LDAP Password: " ); + passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") ); passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0; } } @@ -187,7 +186,7 @@ static int dodelete( LDAPMessage *res; if ( verbose ) { - printf( "%sdeleting entry \"%s\"\n", + printf( _("%sdeleting entry \"%s\"\n"), (not ? "!" : ""), dn ); } @@ -224,20 +223,20 @@ static int dodelete( if( verbose || code != LDAP_SUCCESS || (matcheddn && *matcheddn) || (text && *text) || (refs && *refs) ) { - printf( "Delete Result: %s (%d)\n", ldap_err2string( code ), code ); + printf( _("Delete Result: %s (%d)\n"), ldap_err2string( code ), code ); if( text && *text ) { - printf( "Additional info: %s\n", text ); + printf( _("Additional info: %s\n"), text ); } if( matcheddn && *matcheddn ) { - printf( "Matched DN: %s\n", matcheddn ); + printf( _("Matched DN: %s\n"), matcheddn ); } if( refs ) { int i; for( i=0; refs[i]; i++ ) { - printf("Referral: %s\n", refs[i] ); + printf(_("Referral: %s\n"), refs[i] ); } } } @@ -262,7 +261,7 @@ static int deletechildren( int rc; static char *attrs[] = { "1.1", NULL }; - if ( verbose ) printf ( "deleting children of: %s\n", dn ); + if ( verbose ) printf ( _("deleting children of: %s\n"), dn ); /* * Do a one level search at dn for children. For each, delete its children. */ @@ -299,7 +298,7 @@ static int deletechildren( } if ( verbose ) { - printf( "\tremoving %s\n", dn ); + printf( _("\tremoving %s\n"), dn ); } rc = ldap_delete_s( ld, dn ); @@ -311,7 +310,7 @@ static int deletechildren( } if ( verbose ) { - printf( "\t%s removed\n", dn ); + printf( _("\t%s removed\n"), dn ); } ber_memfree( dn ); diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index d4f452b95e..e521dc0317 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -89,17 +89,15 @@ static char *read_one_record LDAP_P(( FILE *fp )); void usage( void ) { - fprintf( stderr, -"Add or modify entries from an LDAP server\n\n" -"usage: %s [options]\n" -" The list of desired operations are read from stdin or from the file\n" -" specified by \"-f file\".\n" -"Add or modify options:\n" -" -a add values (default%s)\n" -" -F force all changes records to be used\n" -" -S file write skipped modifications to `file'\n" - , prog, (ldapadd ? "" : " is to replace") ); - tool_common_usage(); + fprintf( stderr, _("Add or modify entries from an LDAP server\n\n")); + fprintf( stderr, _("usage: %s [options]\n"), prog); + fprintf( stderr, _(" The list of desired operations are read from stdin or from the file\n")); + fprintf( stderr, _(" specified by \"-f file\".\n")); + fprintf( stderr, _("Add or modify options:\n")); + fprintf( stderr, _(" -a add values (default%s)\n"), (ldapadd ? "" : _(" is to replace"))); + fprintf( stderr, _(" -F force all changes records to be used\n")); + fprintf( stderr, _(" -S file write skipped modifications to `file'\n")); + tool_common_usage(); exit( EXIT_FAILURE ); } @@ -116,7 +114,7 @@ handle_private_option( int i ) int crit; case 'E': /* modify controls */ if( protocol == LDAP_VERSION2 ) { - fprintf( stderr, "%s: -E incompatible with LDAPv%d\n", + fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"), prog, protocol ); exit( EXIT_FAILURE ); } @@ -136,7 +134,7 @@ handle_private_option( int i ) if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } - fprintf( stderr, "Invalid modify control name: %s\n", control ); + fprintf( stderr, _("Invalid modify control name: %s\n"), control ); usage(); #endif @@ -153,7 +151,7 @@ handle_private_option( int i ) case 'S': /* skipped modifications to file */ if( rejfile != NULL ) { - fprintf( stderr, "%s: -S previously specified\n", prog ); + fprintf( stderr, _("%s: -S previously specified\n"), prog ); exit( EXIT_FAILURE ); } rejfile = ber_strdup( optarg ); @@ -175,6 +173,7 @@ main( int argc, char **argv ) int rc, retval; int count, len; + tool_init(); prog = lutil_progname( "ldapmodify", argc, argv ); /* strncmp instead of strcmp since NT binaries carry .exe extension */ @@ -217,7 +216,7 @@ main( int argc, char **argv ) rc = lutil_get_filed_password( pw_file, &passwd ); if( rc ) return EXIT_FAILURE; } else { - passwd.bv_val = getpassphrase( "Enter LDAP Password: " ); + passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") ); passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0; } } @@ -252,13 +251,13 @@ main( int argc, char **argv ) if ( rc ) retval = rc; if ( rc && rejfp ) { - fprintf(rejfp, "# Error: %s (%d)", ldap_err2string(rc), rc); + fprintf(rejfp, _("# Error: %s (%d)"), ldap_err2string(rc), rc); matched_msg = NULL; ldap_get_option(ld, LDAP_OPT_MATCHED_DN, &matched_msg); if ( matched_msg != NULL ) { if ( *matched_msg != '\0' ) - fprintf( rejfp, ", matched DN: %s", matched_msg ); + fprintf( rejfp, _(", matched DN: %s"), matched_msg ); ldap_memfree( matched_msg ); } @@ -266,7 +265,7 @@ main( int argc, char **argv ) ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &error_msg); if ( error_msg != NULL ) { if ( *error_msg != '\0' ) - fprintf( rejfp, ", additional info: %s", error_msg ); + fprintf( rejfp, _(", additional info: %s"), error_msg ); ldap_memfree( error_msg ); } fprintf( rejfp, "\n%s\n", rejbuf ); @@ -324,7 +323,7 @@ process_ldif_rec( char *rbuf, int count ) } if ( ldif_parse_line( line, &type, &val.bv_val, &val.bv_len ) < 0 ) { - fprintf( stderr, "%s: invalid format (line %d) entry: \"%s\"\n", + fprintf( stderr, _("%s: invalid format (line %d) entry: \"%s\"\n"), prog, linenum, dn == NULL ? "" : dn ); rc = LDAP_PARAM_ERROR; break; @@ -347,7 +346,7 @@ process_ldif_rec( char *rbuf, int count ) strcasecmp( type, T_VERSION_STR ) == 0 ) { if( val.bv_len == 0 || atoi(val.bv_val) != 1 ) { - fprintf( stderr, "%s: invalid version %s, line %d (ignored)\n", + fprintf( stderr, _("%s: invalid version %s, line %d (ignored)\n"), prog, val.bv_val, linenum ); } version++; @@ -369,7 +368,7 @@ process_ldif_rec( char *rbuf, int count ) /* Parse and add it to the list of controls */ rc = parse_ldif_control( line, &pctrls ); if (rc != 0) { - fprintf( stderr, "%s: Error processing %s line, line %d: %s\n", + fprintf( stderr, _("%s: Error processing %s line, line %d: %s\n"), prog, T_CONTROL_STR, linenum, ldap_err2string(rc) ); } goto end_line; @@ -377,9 +376,8 @@ process_ldif_rec( char *rbuf, int count ) expect_ct = 0; if ( !use_record && saw_replica ) { - printf( "%s: skipping change record for entry: %s\n" - "\t(LDAP host/port does not match replica: lines)\n", - prog, dn ); + printf(_("%s: skipping change record for entry: %s\n"), prog, dn); + printf(_("\t(LDAP host/port does not match replica: lines)\n")); free( dn ); ber_memfree( type ); ber_memfree( val.bv_val ); @@ -398,7 +396,7 @@ process_ldif_rec( char *rbuf, int count ) } if ( ++icnt != val.bv_len ) { - fprintf( stderr, "%s: illegal trailing space after \"%s: %s\" trimmed (line %d of entry \"%s\")\n", + fprintf( stderr, _("%s: illegal trailing space after \"%s: %s\" trimmed (line %d of entry \"%s\")\n"), prog, T_CHANGETYPESTR, val.bv_val, linenum, dn ); val.bv_val[icnt] = '\0'; } @@ -418,7 +416,7 @@ process_ldif_rec( char *rbuf, int count ) got_all = delete_entry = 1; } else { fprintf( stderr, - "%s: unknown %s \"%s\" (line %d of entry \"%s\")\n", + _("%s: unknown %s \"%s\" (line %d of entry \"%s\")\n"), prog, T_CHANGETYPESTR, val.bv_val, linenum, dn ); rc = LDAP_PARAM_ERROR; } @@ -443,7 +441,7 @@ process_ldif_rec( char *rbuf, int count ) } if ( ++icnt != val.bv_len ) { - fprintf( stderr, "%s: illegal trailing space after \"%s: %s\" trimmed (line %d of entry \"%s\")\n", + fprintf( stderr, _("%s: illegal trailing space after \"%s: %s\" trimmed (line %d of entry \"%s\")\n"), prog, type, val.bv_val, linenum, dn ); val.bv_val[icnt] = '\0'; } @@ -476,7 +474,7 @@ process_ldif_rec( char *rbuf, int count ) expect_deleteoldrdn = 1; expect_newrdn = 0; } else { - fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n", + fprintf( stderr, _("%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n"), prog, T_NEWRDNSTR, type, linenum, dn ); rc = LDAP_PARAM_ERROR; } @@ -487,7 +485,7 @@ process_ldif_rec( char *rbuf, int count ) expect_newsup = 1; got_all = 1; } else { - fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n", + fprintf( stderr, _("%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n"), prog, T_DELETEOLDRDNSTR, type, linenum, dn ); rc = LDAP_PARAM_ERROR; } @@ -499,13 +497,13 @@ process_ldif_rec( char *rbuf, int count ) } expect_newsup = 0; } else { - fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n", + fprintf( stderr, _("%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n"), prog, T_NEWSUPSTR, type, linenum, dn ); rc = LDAP_PARAM_ERROR; } } else if ( got_all ) { fprintf( stderr, - "%s: extra lines at end (line %d of entry \"%s\")\n", + _("%s: extra lines at end (line %d of entry \"%s\")\n"), prog, linenum, dn ); rc = LDAP_PARAM_ERROR; } else { @@ -811,7 +809,7 @@ domodify( struct berval *bvp; if ( pmods == NULL ) { - fprintf( stderr, "%s: no attributes to change or add (entry=\"%s\")\n", + fprintf( stderr, _("%s: no attributes to change or add (entry=\"%s\")\n"), prog, dn ); return( LDAP_PARAM_ERROR ); } @@ -820,7 +818,7 @@ domodify( op = pmods[ i ]->mod_op & ~LDAP_MOD_BVALUES; if( op == LDAP_MOD_ADD && ( pmods[i]->mod_bvalues == NULL )) { fprintf( stderr, - "%s: attribute \"%s\" has no values (entry=\"%s\")\n", + _("%s: attribute \"%s\" has no values (entry=\"%s\")\n"), prog, pmods[i]->mod_type, dn ); return LDAP_PARAM_ERROR; } @@ -830,8 +828,8 @@ domodify( for ( i = 0; pmods[ i ] != NULL; ++i ) { op = pmods[ i ]->mod_op & ~LDAP_MOD_BVALUES; printf( "%s %s:\n", op == LDAP_MOD_REPLACE ? - "replace" : op == LDAP_MOD_ADD ? - "add" : "delete", pmods[ i ]->mod_type ); + _("replace") : op == LDAP_MOD_ADD ? + _("add") : _("delete"), pmods[ i ]->mod_type ); if ( pmods[ i ]->mod_bvalues != NULL ) { for ( j = 0; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) { bvp = pmods[ i ]->mod_bvalues[ j ]; @@ -843,7 +841,7 @@ domodify( } } if ( notascii ) { - printf( "\tNOT ASCII (%ld bytes)\n", bvp->bv_len ); + printf( _("\tNOT ASCII (%ld bytes)\n"), bvp->bv_len ); } else { printf( "\t%s\n", bvp->bv_val ); } @@ -866,10 +864,10 @@ domodify( } if ( i != LDAP_SUCCESS ) { /* print error message about failed update including DN */ - fprintf( stderr, "%s: update failed: %s\n", prog, dn ); + fprintf( stderr, _("%s: update failed: %s\n"), prog, dn ); ldap_perror( ld, newentry ? "ldap_add" : "ldap_modify" ); } else if ( verbose ) { - printf( "modify complete\n" ); + printf( _("modify complete\n") ); } } else { i = LDAP_SUCCESS; @@ -888,13 +886,13 @@ dodelete( { int rc; - printf( "%sdeleting entry \"%s\"\n", not ? "!" : "", dn ); + printf( _("%sdeleting entry \"%s\"\n"), not ? "!" : "", dn ); if ( !not ) { if (( rc = ldap_delete_ext_s( ld, dn, pctrls, NULL )) != LDAP_SUCCESS ) { - fprintf( stderr, "%s: delete failed: %s\n", prog, dn ); + fprintf( stderr, _("%s: delete failed: %s\n"), prog, dn ); ldap_perror( ld, "ldap_delete" ); } else if ( verbose ) { - printf( "delete complete" ); + printf( _("delete complete") ); } } else { rc = LDAP_SUCCESS; @@ -917,18 +915,18 @@ dorename( int rc; - printf( "%smodifying rdn of entry \"%s\"\n", not ? "!" : "", dn ); + printf( _("%smodifying rdn of entry \"%s\"\n"), not ? "!" : "", dn ); if ( verbose ) { - printf( "\tnew RDN: \"%s\" (%skeep existing values)\n", - newrdn, deleteoldrdn ? "do not " : "" ); + printf( _("\tnew RDN: \"%s\" (%skeep existing values)\n"), + newrdn, deleteoldrdn ? _("do not ") : "" ); } if ( !not ) { if (( rc = ldap_rename_s( ld, dn, newrdn, newsup, deleteoldrdn, pctrls, NULL )) != LDAP_SUCCESS ) { - fprintf( stderr, "%s: rename failed: %s\n", prog, dn ); + fprintf( stderr, _("%s: rename failed: %s\n"), prog, dn ); ldap_perror( ld, "ldap_modrdn" ); } else { - printf( "modrdn completed\n" ); + printf( _("modrdn completed\n") ); } } else { rc = LDAP_SUCCESS; diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c index 225e536657..53db82726d 100644 --- a/clients/tools/ldapmodrdn.c +++ b/clients/tools/ldapmodrdn.c @@ -49,16 +49,14 @@ static int domodrdn( void usage( void ) { - fprintf( stderr, -"Rename LDAP entries\n\n" -"usage: %s [options] [dn rdn]\n" -" dn rdn: If given, rdn will replace the RDN of the entry specified by DN\n" -" If not given, the list of modifications is read from stdin or\n" -" from the file specified by \"-f file\" (see man page).\n" -"Rename options:\n" -" -r remove old RDN\n" -" -s newsup new superior entry\n" - , prog ); + fprintf( stderr, _("Rename LDAP entries\n\n")); + fprintf( stderr, _("usage: %s [options] [dn rdn]\n"), prog); + fprintf( stderr, _(" dn rdn: If given, rdn will replace the RDN of the entry specified by DN\n")); + fprintf( stderr, _(" If not given, the list of modifications is read from stdin or\n")); + fprintf( stderr, _(" from the file specified by \"-f file\" (see man page).\n")); + fprintf( stderr, _("Rename options:\n")); + fprintf( stderr, _(" -r remove old RDN\n")); + fprintf( stderr, _(" -s newsup new superior entry\n")); tool_common_usage(); exit( EXIT_FAILURE ); } @@ -76,7 +74,7 @@ handle_private_option( int i ) char *control, *cvalue; case 'E': /* modrdn controls */ if( protocol == LDAP_VERSION2 ) { - fprintf( stderr, "%s: -E incompatible with LDAPv%d\n", + fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"), prog, version ); exit( EXIT_FAILURE ); } @@ -96,7 +94,7 @@ handle_private_option( int i ) if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } - fprintf( stderr, "Invalid modrdn control name: %s\n", control ); + fprintf( stderr, _("Invalid modrdn control name: %s\n"), control ); usage(); #endif @@ -106,7 +104,7 @@ handle_private_option( int i ) case 's': /* newSuperior */ if( protocol == LDAP_VERSION2 ) { - fprintf( stderr, "%s: -X incompatible with LDAPv%d\n", + fprintf( stderr, _("%s: -X incompatible with LDAPv%d\n"), prog, protocol ); exit( EXIT_FAILURE ); } @@ -129,6 +127,7 @@ main(int argc, char **argv) LDAP *ld; int rc, retval, havedn; + tool_init(); prog = lutil_progname( "ldapmodrdn", argc, argv ); tool_args( argc, argv ); @@ -145,8 +144,7 @@ main(int argc, char **argv) } ++havedn; } else if ( argc - optind != 0 ) { - fprintf( stderr, "%s: invalid number of arguments (%d), " - "only two allowed\n", prog, argc-optind ); + fprintf( stderr, _("%s: invalid number of arguments (%d), only two allowed\n"), prog, argc-optind ); usage(); } @@ -166,7 +164,7 @@ main(int argc, char **argv) rc = lutil_get_filed_password( pw_file, &passwd ); if( rc ) return EXIT_FAILURE; } else { - passwd.bv_val = getpassphrase( "Enter LDAP Password: " ); + passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") ); passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0; } } @@ -219,11 +217,11 @@ static int domodrdn( LDAPMessage *res; if ( verbose ) { - printf( "Renaming \"%s\"\n", dn ); - printf( "\tnew rdn=\"%s\" (%s old rdn)\n", - rdn, remove ? "delete" : "keep" ); + printf( _("Renaming \"%s\"\n"), dn ); + printf( _("\tnew rdn=\"%s\" (%s old rdn)\n"), + rdn, remove ? _("delete") : _("keep") ); if( newSuperior != NULL ) { - printf("\tnew parent=\"%s\"\n", newSuperior); + printf(_("\tnew parent=\"%s\"\n"), newSuperior); } } @@ -255,21 +253,21 @@ static int domodrdn( if( verbose || code != LDAP_SUCCESS || (matcheddn && *matcheddn) || (text && *text) || (refs && *refs) ) { - printf( "Rename Result: %s (%d)\n", + printf( _("Rename Result: %s (%d)\n"), ldap_err2string( code ), code ); if( text && *text ) { - printf( "Additional info: %s\n", text ); + printf( _("Additional info: %s\n"), text ); } if( matcheddn && *matcheddn ) { - printf( "Matched DN: %s\n", matcheddn ); + printf( _("Matched DN: %s\n"), matcheddn ); } if( refs ) { int i; for( i=0; refs[i]; i++ ) { - printf("Referral: %s\n", refs[i] ); + printf(_("Referral: %s\n"), refs[i] ); } } } diff --git a/clients/tools/ldappasswd.c b/clients/tools/ldappasswd.c index 85ef979468..e4353b13ea 100644 --- a/clients/tools/ldappasswd.c +++ b/clients/tools/ldappasswd.c @@ -36,18 +36,16 @@ static char *newpwfile = NULL; void usage( void ) { - fprintf(stderr, -"Change password of an LDAP user\n\n" -"usage: %s [options] [user]\n" -" user: the autentication identity, commonly a DN\n" -"Password change options:\n" -" -a secret old password\n" -" -A prompt for old password\n" -" -t file read file for old password\n" -" -s secret new password\n" -" -S prompt for new password\n" -" -T file read file for new password\n" - , prog ); + fprintf( stderr, _("Change password of an LDAP user\n\n")); + fprintf( stderr,_("usage: %s [options] [user]\n"), prog); + fprintf( stderr, _(" user: the autentication identity, commonly a DN\n")); + fprintf( stderr, _("Password change options:\n")); + fprintf( stderr, _(" -a secret old password\n")); + fprintf( stderr, _(" -A prompt for old password\n")); + fprintf( stderr, _(" -t file read file for old password\n")); + fprintf( stderr, _(" -s secret new password\n")); + fprintf( stderr, _(" -S prompt for new password\n")); + fprintf( stderr, _(" -T file read file for new password\n")); tool_common_usage(); exit( EXIT_FAILURE ); } @@ -65,7 +63,7 @@ handle_private_option( int i ) int crit; char *control, *cvalue; if( protocol == LDAP_VERSION2 ) { - fprintf( stderr, "%s: -E incompatible with LDAPv%d\n", + fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"), prog, protocol ); exit( EXIT_FAILURE ); } @@ -85,8 +83,7 @@ handle_private_option( int i ) if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } - - fprintf( stderr, "Invalid passwd control name: %s\n", control ); + fprintf( stderr, _("Invalid passwd control name: %s\n"), control ); usage(); } #endif @@ -152,6 +149,7 @@ main( int argc, char *argv[] ) char *retoid = NULL; struct berval *retdata = NULL; + tool_init(); prog = lutil_progname( "ldappasswd", argc, argv ); /* LDAPv3 only */ @@ -175,13 +173,13 @@ main( int argc, char *argv[] ) if( want_oldpw && oldpw.bv_val == NULL ) { /* prompt for old password */ char *ckoldpw; - oldpw.bv_val = strdup(getpassphrase("Old password: ")); - ckoldpw = getpassphrase("Re-enter old password: "); + oldpw.bv_val = strdup(getpassphrase(_("Old password: "))); + ckoldpw = getpassphrase(_("Re-enter old password: ")); if( oldpw.bv_val == NULL || ckoldpw == NULL || strcmp( oldpw.bv_val, ckoldpw )) { - fprintf( stderr, "passwords do not match\n" ); + fprintf( stderr, _("passwords do not match\n") ); return EXIT_FAILURE; } @@ -196,13 +194,13 @@ main( int argc, char *argv[] ) if( want_newpw && newpw.bv_val == NULL ) { /* prompt for new password */ char *cknewpw; - newpw.bv_val = strdup(getpassphrase("New password: ")); - cknewpw = getpassphrase("Re-enter new password: "); + newpw.bv_val = strdup(getpassphrase(_("New password: "))); + cknewpw = getpassphrase(_("Re-enter new password: ")); if( newpw.bv_val == NULL || cknewpw == NULL || strcmp( newpw.bv_val, cknewpw )) { - fprintf( stderr, "passwords do not match\n" ); + fprintf( stderr, _("passwords do not match\n") ); return EXIT_FAILURE; } @@ -211,7 +209,7 @@ main( int argc, char *argv[] ) if( want_bindpw && passwd.bv_val == NULL ) { /* handle bind password */ - passwd.bv_val = strdup( getpassphrase("Enter bind password: ")); + passwd.bv_val = strdup( getpassphrase(_("Enter bind password: "))); passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0; } @@ -318,7 +316,7 @@ main( int argc, char *argv[] ) if( tag == LBER_ERROR ) { perror( "ber_scanf" ); } else { - printf("New password: %s\n", s); + printf(_("New password: %s\n"), s); free( s ); } @@ -326,20 +324,20 @@ main( int argc, char *argv[] ) } if( verbose || code != LDAP_SUCCESS || matcheddn || text || refs ) { - printf( "Result: %s (%d)\n", ldap_err2string( code ), code ); + printf( _("Result: %s (%d)\n"), ldap_err2string( code ), code ); if( text && *text ) { - printf( "Additional info: %s\n", text ); + printf( _("Additional info: %s\n"), text ); } if( matcheddn && *matcheddn ) { - printf( "Matched DN: %s\n", matcheddn ); + printf( _("Matched DN: %s\n"), matcheddn ); } if( refs ) { int i; for( i=0; refs[i]; i++ ) { - printf("Referral: %s\n", refs[i] ); + printf(_("Referral: %s\n"), refs[i] ); } } } diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index 83cae190b6..6577652f15 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -50,55 +50,54 @@ static char *def_urlpre; void usage( void ) { - fprintf( stderr, -"usage: %s [options] [filter [attributes...]]\nwhere:\n" -" filter\tRFC-2254 compliant LDAP search filter\n" -" attributes\twhitespace-separated list of attribute descriptions\n" -" which may include:\n" -" 1.1 no attributes\n" -" * all user attributes\n" -" + all operational attributes\n" - -"Search options:\n" -" -a deref one of never (default), always, search, or find\n" -" -A retrieve attribute names only (no values)\n" -" -b basedn base dn for search\n" -" -E [!][=] search controls (! indicates criticality)\n" + fprintf( stderr, _("usage: %s [options] [filter [attributes...]]\nwhere:\n"), prog); + fprintf( stderr, _(" filter\tRFC-2254 compliant LDAP search filter\n")); + fprintf( stderr, _(" attributes\twhitespace-separated list of attribute descriptions\n")); + fprintf( stderr, _(" which may include:\n")); + fprintf( stderr, _(" 1.1 no attributes\n")); + fprintf( stderr, _(" * all user attributes\n")); + fprintf( stderr, _(" + all operational attributes\n")); + + + fprintf( stderr, _("Search options:\n")); + fprintf( stderr, _(" -a deref one of never (default), always, search, or find\n")); + fprintf( stderr, _(" -A retrieve attribute names only (no values)\n")); + fprintf( stderr, _(" -b basedn base dn for search\n")); + fprintf( stderr, _(" -E [!][=] search controls (! indicates criticality)\n")); #ifdef LDAP_CONTROL_X_DOMAIN_SCOPE -" [!]domainScope (domain scope)\n" + fprintf( stderr, _(" [!]domainScope (domain scope)\n")); #endif -" [!]mv= (matched values filter)\n" + fprintf( stderr, _(" [!]mv= (matched values filter)\n")); #ifdef LDAP_CONTROL_PAGEDRESULTS -" [!]pr= (paged results)\n" + fprintf( stderr, _(" [!]pr= (paged results)\n")); #endif #ifdef LDAP_CONTROL_SUBENTRIES -" [!]subentries[=true|false] (subentries)\n" + fprintf( stderr, _(" [!]subentries[=true|false] (subentries)\n")); #endif #ifdef LDAP_CLIENT_UPDATE -" [!]lcup=p/// (LDAP client update)\n" + fprintf( stderr, _(" [!]lcup=p/// (LDAP client update)\n")); /* * " s// (LDAP client update)\n" * " sp///\n" * */ #endif #ifdef LDAP_SYNC -" [!]sync=ro[/] (LDAP Sync refreshOnly)\n" -" rp[/][/] (LDAP Sync refreshAndPersist)\n" + fprintf( stderr, _(" [!]sync=ro[/] (LDAP Sync refreshOnly)\n")); + fprintf( stderr, _(" rp[/][/] (LDAP Sync refreshAndPersist)\n")); #endif -" -F prefix URL prefix for files (default: %s)\n" -" -l limit time limit (in seconds) for search\n" -" -L print responses in LDIFv1 format\n" -" -LL print responses in LDIF format without comments\n" -" -LLL print responses in LDIF format without comments\n" -" and version\n" -" -s scope one of base, one, or sub (search scope)\n" -" -S attr sort the results by attribute `attr'\n" -" -t write binary values to files in temporary directory\n" -" -tt write all values to files in temporary directory\n" -" -T path write files to directory specified by path (default: %s)\n" -" -u include User Friendly entry names in the output\n" -" -z limit size limit (in entries) for search\n" - , prog, def_urlpre, def_tmpdir ); + fprintf( stderr, _(" -F prefix URL prefix for files (default: %s)\n"), def_urlpre); + fprintf( stderr, _(" -l limit time limit (in seconds) for search\n")); + fprintf( stderr, _(" -L print responses in LDIFv1 format\n")); + fprintf( stderr, _(" -LL print responses in LDIF format without comments\n")); + fprintf( stderr, _(" -LLL print responses in LDIF format without comments\n")); + fprintf( stderr, _(" and version\n")); + fprintf( stderr, _(" -s scope one of base, one, or sub (search scope)\n")); + fprintf( stderr, _(" -S attr sort the results by attribute `attr'\n")); + fprintf( stderr, _(" -t write binary values to files in temporary directory\n")); + fprintf( stderr, _(" -tt write all values to files in temporary directory\n")); + fprintf( stderr, _(" -T path write files to directory specified by path (default: %s)\n"), def_tmpdir); + fprintf( stderr, _(" -u include User Friendly entry names in the output\n")); + fprintf( stderr, _(" -z limit size limit (in entries) for search\n")); tool_common_usage(); exit( EXIT_FAILURE ); } @@ -227,7 +226,7 @@ handle_private_option( int i ) } else if ( strcasecmp( optarg, "always" ) == 0 ) { deref = LDAP_DEREF_ALWAYS; } else { - fprintf( stderr, "alias deref should be never, search, find, or always\n" ); + fprintf( stderr, _("alias deref should be never, search, find, or always\n") ); usage(); } break; @@ -239,7 +238,7 @@ handle_private_option( int i ) break; case 'E': /* search controls */ if( protocol == LDAP_VERSION2 ) { - fprintf( stderr, "%s: -E incompatible with LDAPv%d\n", + fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"), prog, protocol ); exit( EXIT_FAILURE ); } @@ -263,14 +262,14 @@ handle_private_option( int i ) if ( strcasecmp( control, "mv" ) == 0 ) { /* ValuesReturnFilter control */ if( valuesReturnFilter ) { - fprintf( stderr, "ValuesReturnFilter previously specified\n"); + fprintf( stderr, _("ValuesReturnFilter previously specified\n")); exit( EXIT_FAILURE ); } valuesReturnFilter= 1 + crit; if ( cvalue == NULL ) { fprintf( stderr, - "missing filter in ValuesReturnFilter control\n"); + _("missing filter in ValuesReturnFilter control\n")); exit( EXIT_FAILURE ); } @@ -282,13 +281,13 @@ handle_private_option( int i ) int num, tmp; /* PagedResults control */ if ( pagedResults != 0 ) { - fprintf( stderr, "PagedResultsControl previously specified\n" ); + fprintf( stderr, _("PagedResultsControl previously specified\n") ); exit( EXIT_FAILURE ); } num = sscanf( cvalue, "%d", &tmp ); if ( num != 1 ) { - fprintf( stderr, "Invalid value for PagedResultsControl, %s.\n", cvalue); + fprintf( stderr, _("Invalid value for PagedResultsControl, %s.\n"), cvalue); exit( EXIT_FAILURE ); } @@ -300,12 +299,12 @@ handle_private_option( int i ) } else if ( strcasecmp( control, "domainScope" ) == 0 ) { if( domainScope ) { fprintf( stderr, - "domainScope control previously specified\n"); + _("domainScope control previously specified\n")); exit( EXIT_FAILURE ); } if( cvalue != NULL ) { fprintf( stderr, - "domainScope: no control value expected\n" ); + _("domainScope: no control value expected\n") ); usage(); } @@ -314,7 +313,7 @@ handle_private_option( int i ) #ifdef LDAP_CONTROL_SUBENTRIES } else if ( strcasecmp( control, "subentries" ) == 0 ) { if( subentries ) { - fprintf( stderr, "subentries control previously specified\n"); + fprintf( stderr, _("subentries control previously specified\n")); exit( EXIT_FAILURE ); } if( cvalue == NULL || strcasecmp( cvalue, "true") == 0 ) { @@ -323,7 +322,7 @@ handle_private_option( int i ) subentries = 1; } else { fprintf( stderr, - "subentries control value \"%s\" invalid\n", + _("subentries control value \"%s\" invalid\n"), cvalue ); exit( EXIT_FAILURE ); } @@ -335,16 +334,16 @@ handle_private_option( int i ) char *cookiep; char *slimitp; if ( lcup ) { - fprintf( stderr, "client update control previously specified\n"); + fprintf( stderr, _("client update control previously specified\n")); exit( EXIT_FAILURE ); } if ( ldapsync != -1 ) { - fprintf( stderr, "ldap sync control previously specified\n"); + fprintf( stderr, _("ldap sync control previously specified\n")); exit( EXIT_FAILURE ); } if ( cvalue == NULL ) { fprintf( stderr, - "missing specification of client update control\n"); + _("missing specification of client update control\n")); exit( EXIT_FAILURE ); } if ( strncasecmp( cvalue, "p", 1 ) == 0 ) { @@ -382,7 +381,7 @@ handle_private_option( int i ) */ } else { fprintf( stderr, - "client update control value \"%s\" invalid\n", + _("client update control value \"%s\" invalid\n"), cvalue ); exit( EXIT_FAILURE ); } @@ -394,16 +393,16 @@ handle_private_option( int i ) char *cookiep; char *slimitp; if ( ldapsync ) { - fprintf( stderr, "ldap sync control previously specified\n" ); + fprintf( stderr, _("ldap sync control previously specified\n") ); exit( EXIT_FAILURE ); } if ( lcup ) { - fprintf( stderr, "client update control previously specified\n" ); + fprintf( stderr, _("client update control previously specified\n") ); exit( EXIT_FAILURE ); } if ( cvalue == NULL ) { fprintf( stderr, - "missing specification of ldap sync control\n"); + _("missing specification of ldap sync control\n")); exit( EXIT_FAILURE ); } if ( strncasecmp( cvalue, "ro", 2 ) == 0 ) { @@ -432,7 +431,7 @@ handle_private_option( int i ) sync_slimit = atoi( slimitp ); } else { fprintf( stderr, - "ldap sync control value \"%s\" invalid\n", + _("ldap sync control value \"%s\" invalid\n"), cvalue ); exit( EXIT_FAILURE ); } @@ -440,7 +439,7 @@ handle_private_option( int i ) #endif } else { - fprintf( stderr, "Invalid control name: %s\n", control ); + fprintf( stderr, _("Invalid control name: %s\n"), control ); usage(); } break; @@ -451,7 +450,7 @@ handle_private_option( int i ) case 'l': /* time limit */ timelimit = atoi( optarg ); if( timelimit < 0 ) { - fprintf( stderr, "%s: invalid timelimit (%d) specified\n", + fprintf( stderr, _("%s: invalid timelimit (%d) specified\n"), prog, timelimit ); exit( EXIT_FAILURE ); } @@ -467,7 +466,7 @@ handle_private_option( int i ) } else if ( strncasecmp( optarg, "sub", sizeof("sub")-1 ) == 0 ) { scope = LDAP_SCOPE_SUBTREE; } else { - fprintf( stderr, "scope should be base, one, or sub\n" ); + fprintf( stderr, _("scope should be base, one, or sub\n") ); usage(); } break; @@ -500,19 +499,19 @@ private_conn_setup( LDAP *ld ) if (deref != -1 && ldap_set_option( ld, LDAP_OPT_DEREF, (void *) &deref ) != LDAP_OPT_SUCCESS ) { - fprintf( stderr, "Could not set LDAP_OPT_DEREF %d\n", deref ); + fprintf( stderr, _("Could not set LDAP_OPT_DEREF %d\n"), deref ); exit( EXIT_FAILURE ); } if (timelimit != -1 && ldap_set_option( ld, LDAP_OPT_TIMELIMIT, (void *) &timelimit ) != LDAP_OPT_SUCCESS ) { - fprintf( stderr, "Could not set LDAP_OPT_TIMELIMIT %d\n", timelimit ); + fprintf( stderr, _("Could not set LDAP_OPT_TIMELIMIT %d\n"), timelimit ); exit( EXIT_FAILURE ); } if (sizelimit != -1 && ldap_set_option( ld, LDAP_OPT_SIZELIMIT, (void *) &sizelimit ) != LDAP_OPT_SUCCESS ) { - fprintf( stderr, "Could not set LDAP_OPT_SIZELIMIT %d\n", sizelimit ); + fprintf( stderr, _("Could not set LDAP_OPT_SIZELIMIT %d\n"), sizelimit ); exit( EXIT_FAILURE ); } } @@ -536,6 +535,8 @@ main( int argc, char **argv ) struct berval *syncbvalp = NULL; #endif + tool_init(); + #ifdef LDAP_CONTROL_PAGEDRESULTS npagedresponses = npagedentries = npagedreferences = npagedextended = npagedpartial = 0; @@ -622,7 +623,7 @@ main( int argc, char **argv ) rc = lutil_get_filed_password( pw_file, &passwd ); if( rc ) return EXIT_FAILURE; } else { - passwd.bv_val = getpassphrase( "Enter LDAP Password: " ); + passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") ); passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0; } } @@ -667,7 +668,7 @@ getNextPage: err = ber_printf( seber, "{b}", abs(subentries) == 1 ? 0 : 1 ); if ( err == -1 ) { ber_free( seber, 1 ); - fprintf( stderr, "Subentries control encoding error!\n" ); + fprintf( stderr, _("Subentries control encoding error!\n") ); return EXIT_FAILURE; } @@ -696,7 +697,7 @@ getNextPage: if ( err == LBER_ERROR ) { ber_free( cuber, 1 ); - fprintf( stderr, "client update control encoding error!\n" ); + fprintf( stderr, _("client update control encoding error!\n") ); return EXIT_FAILURE; } @@ -726,7 +727,7 @@ getNextPage: if ( err == LBER_ERROR ) { ber_free( syncber, 1 ); - fprintf( stderr, "ldap sync control encoding error!\n" ); + fprintf( stderr, _("ldap sync control encoding error!\n") ); return EXIT_FAILURE; } @@ -748,7 +749,7 @@ getNextPage: if ( ( err = ldap_put_vrFilter( vrber, vrFilter ) ) == -1 ) { ber_free( vrber, 1 ); - fprintf( stderr, "Bad ValuesReturnFilter: %s\n", vrFilter ); + fprintf( stderr, _("Bad ValuesReturnFilter: %s\n"), vrFilter ); return EXIT_FAILURE; } @@ -786,12 +787,12 @@ getNextPage: } if ( verbose ) { - fprintf( stderr, "filter%s: %s\nrequesting: ", - infile != NULL ? " pattern" : "", + fprintf( stderr, _("filter%s: %s\nrequesting: "), + infile != NULL ? _(" pattern") : "", filtpattern ); if ( attrs == NULL ) { - fprintf( stderr, "ALL" ); + fprintf( stderr, _("ALL") ); } else { for ( i = 0; attrs[ i ] != NULL; ++i ) { fprintf( stderr, "%s ", attrs[ i ] ); @@ -801,25 +802,23 @@ getNextPage: } if ( ldif == 0 ) { - printf( "# extended LDIF\n" ); + printf( _("# extended LDIF\n") ); } else if ( ldif < 3 ) { - printf( "version: %d\n\n", 1 ); + printf( _("version: %d\n\n"), 1 ); } if (ldif < 2 ) { - printf( "#\n" - "# LDAPv%d\n" - "# base <%s> with scope %s\n" - "# filter%s: %s\n" - "# requesting: ", - protocol, + printf( "#\n" ); + printf(_("# LDAPv%d\n"), protocol); + printf(_("# base <%s> with scope %s\n"), base ? base : "", (scope == LDAP_SCOPE_BASE) ? "base" - : ((scope == LDAP_SCOPE_ONELEVEL) ? "one" : "sub"), - infile != NULL ? " pattern" : "", - filtpattern ); + : ((scope == LDAP_SCOPE_ONELEVEL) ? "one" : "sub")); + printf(_("# filter%s: %s\n"), infile != NULL ? _(" pattern") : "", + filtpattern); + printf(_("# requesting: ")); if ( attrs == NULL ) { - printf( "ALL" ); + printf( _("ALL") ); } else { for ( i = 0; attrs[ i ] != NULL; ++i ) { printf( "%s ", attrs[ i ] ); @@ -827,31 +826,31 @@ getNextPage: } if ( manageDSAit ) { - printf("\n# with manageDSAit %scontrol", - manageDSAit > 1 ? "critical " : "" ); + printf(_("\n# with manageDSAit %scontrol"), + manageDSAit > 1 ? _("critical ") : "" ); } if ( noop ) { - printf("\n# with noop %scontrol", - noop > 1 ? "critical " : "" ); + printf(_("\n# with noop %scontrol"), + noop > 1 ? _("critical ") : "" ); } if ( subentries ) { - printf("\n# with subentries %scontrol: %s", - subentries < 0 ? "critical " : "", + printf(_("\n# with subentries %scontrol: %s"), + subentries < 0 ? _("critical ") : "", abs(subentries) == 1 ? "false" : "true" ); } if ( valuesReturnFilter ) { - printf("\n# with valuesReturnFilter %scontrol: %s", - valuesReturnFilter > 1 ? "critical " : "", vrFilter ); + printf(_("\n# with valuesReturnFilter %scontrol: %s"), + valuesReturnFilter > 1 ? _("critical ") : "", vrFilter ); } #ifdef LDAP_CONTROL_PAGEDRESULTS if ( pageSize ) { - printf("\n# with pagedResults %scontrol: size=%d", - (pagedResults > 1) ? "critical " : "", + printf(_("\n# with pagedResults %scontrol: size=%d"), + (pagedResults > 1) ? _("critical ") : "", pageSize ); } #endif - printf( "\n#\n\n" ); + printf( _("\n#\n\n") ); } if ( infile == NULL ) { @@ -885,9 +884,9 @@ getNextPage: * enter is pressed on the terminal. */ if ( entriesLeft > 0 ) { - printf( "Estimate entries: %d\n", entriesLeft ); + printf( _("Estimate entries: %d\n"), entriesLeft ); } - printf( "Press [size] Enter for the next {%d|size} entries.\n", + printf( _("Press [size] Enter for the next {%d|size} entries.\n"), (int)pageSize ); i = 0; moreEntries = getchar(); @@ -903,7 +902,7 @@ getNextPage: if ( i > 0 && isdigit( (unsigned char)buf[0] ) ) { int num = sscanf( buf, "%d", &tmpSize ); if ( num != 1 ) { - fprintf( stderr, "Invalid value for PagedResultsControl, %s.\n", buf); + fprintf( stderr, _("Invalid value for PagedResultsControl, %s.\n"), buf); return EXIT_FAILURE; } @@ -960,11 +959,11 @@ static int dosearch( sprintf( filter, filtpatt, value ); if ( verbose ) { - fprintf( stderr, "filter: %s\n", filter ); + fprintf( stderr, _("filter: %s\n"), filter ); } if( ldif < 2 ) { - printf( "#\n# filter: %s\n#\n", filter ); + printf( _("#\n# filter: %s\n#\n"), filter ); } } else { @@ -983,7 +982,7 @@ static int dosearch( } if( rc != LDAP_SUCCESS ) { - fprintf( stderr, "%s: ldap_search_ext: %s (%d)\n", + fprintf( stderr, _("%s: ldap_search_ext: %s (%d)\n"), prog, ldap_err2string( rc ), rc ); return( rc ); } @@ -1034,8 +1033,8 @@ static int dosearch( #ifdef LDAP_SYNC if ( cancel_msgid != -1 && cancel_msgid == ldap_msgid( msg ) ) { - printf("Cancelled \n"); - printf("cancel_msgid = %d\n", cancel_msgid); + printf(_("Cancelled \n")); + printf(_("cancel_msgid = %d\n"), cancel_msgid); goto done; } #endif @@ -1078,12 +1077,12 @@ static int dosearch( nresponses_psearch = 0; if ( strcmp( retoid, LDAP_SYNC_INFO ) ) { - printf("Unexpected Intermediate Response\n"); + printf(_("Unexpected Intermediate Response\n")); ldap_memfree( retoid ); ber_bvfree( retdata ); goto done; } else { - printf("SyncInfo Received\n"); + printf(_("SyncInfo Received\n")); ldap_memfree( retoid ); ber_bvfree( retdata ); break; @@ -1131,20 +1130,20 @@ done: npagedextended = npagedextended + nextended; npagedpartial = npagedpartial + npartial; if ( ( morePagedResults == 0 ) && ( ldif < 2 ) ) { - printf( "\n# numResponses: %d\n", npagedresponses ); - if( nentries ) printf( "# numEntries: %d\n", npagedentries ); - if( nextended ) printf( "# numExtended: %d\n", npagedextended ); - if( npartial ) printf( "# numPartial: %d\n", npagedpartial ); - if( nreferences ) printf( "# numReferences: %d\n", npagedreferences ); + printf( _("\n# numResponses: %d\n"), npagedresponses ); + if( nentries ) printf( _("# numEntries: %d\n"), npagedentries ); + if( nextended ) printf( _("# numExtended: %d\n"), npagedextended ); + if( npartial ) printf( _("# numPartial: %d\n"), npagedpartial ); + if( nreferences ) printf( _("# numReferences: %d\n"), npagedreferences ); } } else #endif if ( ldif < 2 ) { - printf( "\n# numResponses: %d\n", nresponses ); - if( nentries ) printf( "# numEntries: %d\n", nentries ); - if( nextended ) printf( "# numExtended: %d\n", nextended ); - if( npartial ) printf( "# numPartial: %d\n", npartial ); - if( nreferences ) printf( "# numReferences: %d\n", nreferences ); + printf( _("\n# numResponses: %d\n"), nresponses ); + if( nentries ) printf( _("# numEntries: %d\n"), nentries ); + if( nextended ) printf( _("# numExtended: %d\n"), nextended ); + if( npartial ) printf( _("# numPartial: %d\n"), npartial ); + if( nreferences ) printf( _("# numReferences: %d\n"), nreferences ); } return( rc ); @@ -1179,7 +1178,7 @@ print_entry( rc = ldap_get_entry_controls( ld, entry, &ctrls ); if( rc != LDAP_SUCCESS ) { - fprintf(stderr, "print_entry: %d\n", rc ); + fprintf(stderr, _("print_entry: %d\n"), rc ); ldap_perror( ld, "ldap_get_entry_controls" ); exit( EXIT_FAILURE ); } @@ -1289,7 +1288,7 @@ print_entry( rc = ldap_int_get_controls( ber, &ctrls ); if( rc != LDAP_SUCCESS ) { - fprintf(stderr, "print_entry: %d\n", rc ); + fprintf(stderr, _("print_entry: %d\n"), rc ); ldap_perror( ld, "ldap_get_entry_controls" ); exit( EXIT_FAILURE ); } @@ -1383,7 +1382,7 @@ static void print_reference( LDAPControl **ctrls; if( ldif < 2 ) { - printf("# search reference\n"); + printf(_("# search reference\n")); } rc = ldap_parse_reference( ld, reference, &refs, &ctrls, 0 ); @@ -1417,7 +1416,7 @@ static void print_extended( struct berval *retdata = NULL; if( ldif < 2 ) { - printf("# extended result response\n"); + printf(_("# extended result response\n")); } rc = ldap_parse_extended_result( ld, extended, @@ -1455,7 +1454,7 @@ static void print_partial( LDAPControl **ctrls = NULL; if( ldif < 2 ) { - printf("# extended partial response\n"); + printf(_("# extended partial response\n")); } rc = ldap_parse_extended_partial( ld, partial, @@ -1501,10 +1500,10 @@ static int print_result( if( search ) { if ( ldif < 2 ) { - printf("# search result\n"); + printf(_("# search result\n")); } if ( ldif < 1 ) { - printf("%s: %d\n", "search", ldap_msgid(result) ); + printf("%s: %d\n", _("search"), ldap_msgid(result) ); } } @@ -1518,7 +1517,7 @@ static int print_result( if( !ldif ) { - printf( "result: %d %s\n", err, ldap_err2string(err) ); + printf( _("result: %d %s\n"), err, ldap_err2string(err) ); } else if ( err != LDAP_SUCCESS ) { fprintf( stderr, "%s (%d)\n", ldap_err2string(err), err ); @@ -1530,7 +1529,7 @@ static int print_result( write_ldif( LDIF_PUT_VALUE, "matchedDN", matcheddn, strlen(matcheddn) ); } else { - fprintf( stderr, "Matched DN: %s\n", matcheddn ); + fprintf( stderr, _("Matched DN: %s\n"), matcheddn ); } } @@ -1543,7 +1542,7 @@ static int print_result( write_ldif( LDIF_PUT_TEXT, "text", text, strlen(text) ); } else { - fprintf( stderr, "Additional information: %s\n", text ); + fprintf( stderr, _("Additional information: %s\n"), text ); } } @@ -1556,7 +1555,7 @@ static int print_result( if( !ldif ) { write_ldif( LDIF_PUT_VALUE, "ref", refs[i], strlen(refs[i]) ); } else { - fprintf( stderr, "Referral: %s\n", refs[i] ); + fprintf( stderr, _("Referral: %s\n"), refs[i] ); } } @@ -1684,7 +1683,7 @@ parse_page_control( ctrlp = *ctrl; ber = ber_init( &ctrlp->ldctl_value ); if ( ber == NULL ) { - fprintf( stderr, "Internal error.\n" ); + fprintf( stderr, _("Internal error.\n") ); return EXIT_FAILURE; } @@ -1694,13 +1693,13 @@ parse_page_control( if( tag == LBER_ERROR ) { fprintf( stderr, - "Paged results response control could not be decoded.\n" ); + _("Paged results response control could not be decoded.\n") ); return EXIT_FAILURE; } if( entriesLeft < 0 ) { fprintf( stderr, - "Invalid entries estimate in paged results response.\n" ); + _("Invalid entries estimate in paged results response.\n") ); return EXIT_FAILURE; } diff --git a/clients/tools/ldapwhoami.c b/clients/tools/ldapwhoami.c index 4ccb11aea2..f81971dde0 100644 --- a/clients/tools/ldapwhoami.c +++ b/clients/tools/ldapwhoami.c @@ -27,10 +27,8 @@ void usage( void ) { - fprintf(stderr, -"Issue LDAP Who am I? operation to request user's authzid\n\n" -"usage: %s [options]\n" - , prog); + fprintf( stderr, _("Issue LDAP Who am I? operation to request user's authzid\n\n")); + fprintf( stderr, _("usage: %s [options]\n"), prog); tool_common_usage(); exit( EXIT_FAILURE ); } @@ -48,7 +46,7 @@ handle_private_option( int i ) int crit; case 'E': /* whoami controls */ if( protocol == LDAP_VERSION2 ) { - fprintf( stderr, "%s: -E incompatible with LDAPv%d\n", + fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"), prog, protocol ); exit( EXIT_FAILURE ); } @@ -68,7 +66,7 @@ handle_private_option( int i ) if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } - fprintf( stderr, "Invalid whoami control name: %s\n", control ); + fprintf( stderr, _("Invalid whoami control name: %s\n"), control ); usage(); #endif @@ -91,6 +89,7 @@ main( int argc, char *argv[] ) char *retoid = NULL; struct berval *retdata = NULL; + tool_init(); prog = lutil_progname( "ldapwhoami", argc, argv ); /* LDAPv3 only */ @@ -111,7 +110,7 @@ main( int argc, char *argv[] ) rc = lutil_get_filed_password( pw_file, &passwd ); if( rc ) return EXIT_FAILURE; } else { - passwd.bv_val = getpassphrase( "Enter LDAP Password: " ); + passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") ); passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0; } } @@ -132,27 +131,27 @@ main( int argc, char *argv[] ) if( retdata != NULL ) { if( retdata->bv_len == 0 ) { - printf("anonymous\n" ); + printf(_("anonymous\n") ); } else { printf("%s\n", retdata->bv_val ); } } if( verbose || ( rc != LDAP_SUCCESS ) || matcheddn || text || refs ) { - printf( "Result: %s (%d)\n", ldap_err2string( rc ), rc ); + printf( _("Result: %s (%d)\n"), ldap_err2string( rc ), rc ); if( text && *text ) { - printf( "Additional info: %s\n", text ); + printf( _("Additional info: %s\n"), text ); } if( matcheddn && *matcheddn ) { - printf( "Matched DN: %s\n", matcheddn ); + printf( _("Matched DN: %s\n"), matcheddn ); } if( refs ) { int i; for( i=0; refs[i]; i++ ) { - printf("Referral: %s\n", refs[i] ); + printf(_("Referral: %s\n"), refs[i] ); } } }