#endif
typedef int (MainFunc) LDAP_P(( int argc, char *argv[] ));
-extern MainFunc slapadd, slapcat, slapdn, slapindex, slappasswd, slaptest, slapsaslauth;
+extern MainFunc slapadd, slapcat, slapdn, slapindex, slappasswd,
+ slaptest, slapauth;
static struct {
char *name;
{"slapindex", slapindex},
{"slappasswd", slappasswd},
{"slaptest", slaptest},
- {"slapsaslauth", slapsaslauth},
+ {"slapauth", slapauth},
+ /* NOTE: new tools must be added in chronological order,
+ * not in alphabetical order, because for backwards
+ * compatibility name[4] is used to identify the
+ * tools; so name[4]=='a' must refer to "slapadd" and
+ * not to "slapauth". Alphabetical order can be used
+ * for tools whose name[4] is not used yet */
{NULL, NULL}
};
fprintf( stderr,
"\t-4\t\tIPv4 only\n"
"\t-6\t\tIPv6 only\n"
- "\t-T {acdipt}\tRun in Tool mode\n"
+ "\t-T {add|auth|cat|dn|index|passwd|test}\n"
+ "\t\t\tRun in Tool mode\n"
"\t-c cookie\tSync cookie of consumer\n"
"\t-d level\tDebug level" "\n"
"\t-f filename\tConfiguration file\n"
leakfile = stderr;
}
#endif
+ char *serverNamePrefix = "";
+ size_t l;
sl_mem_init();
break;
case 'T':
- for (i=0; tools[i].name; i++) {
- if ( optarg[0] == tools[i].name[4] ) {
- rc = tools[i].func(argc, argv);
- MAIN_RETURN(rc);
+ /* try full option string first */
+ for ( i = 0; tools[i].name; i++ ) {
+ if ( strcmp( optarg, &tools[i].name[4] ) == 0 ) {
+ rc = tools[i].func( argc, argv );
+ MAIN_RETURN( rc );
}
}
+
+ /* try bits of option string (backward compatibility for single char) */
+ l = strlen( optarg );
+ for ( i = 0; tools[i].name; i++ ) {
+ if ( strncmp( optarg, &tools[i].name[4], l ) == 0 ) {
+ rc = tools[i].func( argc, argv );
+ MAIN_RETURN( rc );
+ }
+ }
+
+ /* issue error */
+ serverName = optarg;
+ serverNamePrefix = "slap";
+ fprintf( stderr, "program name \"%s%s\" unrecognized; "
+ "aborting...\n", serverNamePrefix, serverName );
/* FALLTHRU */
default:
usage( argv[0] );