int main( int argc, char **argv ) { int i; char *uri = NULL; char *host = "localhost"; int port = -1; char *manager = NULL; char *passwd = NULL; char *entry = NULL; int loops = LOOPS; while ( (i = getopt( argc, argv, "H:h:p:D:w:e:l:" )) != EOF ) { switch( i ) { case 'H': /* the server uri */ uri = strdup( optarg ); break; case 'h': /* the servers host */ host = strdup( optarg ); break; case 'p': /* the servers port */ port = atoi( optarg ); break; case 'D': /* the servers manager */ manager = strdup( optarg ); break; case 'w': /* the server managers password */ passwd = strdup( optarg ); break; case 'e': /* entry to rename */ entry = strdup( optarg ); break; case 'l': /* the number of loops */ loops = atoi( optarg ); break; default: usage( argv[0] ); break; } } if (( entry == NULL ) || ( port == -1 && uri == NULL )) usage( argv[0] ); if ( *entry == '\0' ) { fprintf( stderr, "%s: invalid EMPTY entry DN.\n", argv[0] ); exit( EXIT_FAILURE ); } do_modrdn( uri, host, port, manager, passwd, entry, loops ); exit( EXIT_SUCCESS ); }
int main( int argc, char **argv ) { int i; char *uri = NULL; char *host = "localhost"; int port = -1; char *manager = NULL; struct berval passwd = { 0, NULL }; char *entry = NULL; int loops = LOOPS; int outerloops = 1; int retries = RETRIES; int delay = 0; int friendly = 0; int chaserefs = 0; tester_init( "slapd-modrdn", TESTER_MODRDN ); while ( ( i = getopt( argc, argv, "CD:e:FH:h:i:L:l:p:r:t:w:" ) ) != EOF ) { switch ( i ) { case 'C': chaserefs++; break; case 'F': friendly++; break; case 'H': /* the server uri */ uri = strdup( optarg ); break; case 'h': /* the servers host */ host = strdup( optarg ); break; case 'i': /* ignored (!) by now */ break; case 'p': /* the servers port */ if ( lutil_atoi( &port, optarg ) != 0 ) { usage( argv[0] ); } break; case 'D': /* the servers manager */ manager = strdup( optarg ); break; case 'w': /* the server managers password */ passwd.bv_val = strdup( optarg ); passwd.bv_len = strlen( optarg ); memset( optarg, '*', passwd.bv_len ); break; case 'e': /* entry to rename */ entry = strdup( optarg ); break; case 'l': /* the number of loops */ if ( lutil_atoi( &loops, optarg ) != 0 ) { usage( argv[0] ); } break; case 'L': /* the number of outerloops */ if ( lutil_atoi( &outerloops, optarg ) != 0 ) { usage( argv[0] ); } break; case 'r': /* the number of retries */ if ( lutil_atoi( &retries, optarg ) != 0 ) { usage( argv[0] ); } break; case 't': /* delay in seconds */ if ( lutil_atoi( &delay, optarg ) != 0 ) { usage( argv[0] ); } break; default: usage( argv[0] ); break; } } if (( entry == NULL ) || ( port == -1 && uri == NULL )) usage( argv[0] ); if ( *entry == '\0' ) { fprintf( stderr, "%s: invalid EMPTY entry DN.\n", argv[0] ); exit( EXIT_FAILURE ); } uri = tester_uri( uri, host, port ); for ( i = 0; i < outerloops; i++ ) { do_modrdn( uri, manager, &passwd, entry, loops, retries, delay, friendly, chaserefs ); } exit( EXIT_SUCCESS ); }