int main(int argc, char *argv[]) { extern char *optarg; extern int optind; int i, ch; progname = argv[0]; /* read command line arguments */ while ((ch = getopt(argc, argv, "Vht:")) != -1) switch((char)ch) { case 'h': scans |= FLAG_HIST; break; case 'V': fprintf(stdout, "Stegcompare Version %s\n", VERSION); exit(1); case 't': scans &= ~(FLAG_DOOUTGUESS|FLAG_DOJPHIDE); for (i = 0; i < strlen(optarg) && !scans; i++) switch(optarg[i]) { case 'o': scans |= FLAG_DOOUTGUESS; break; case 'p': scans |= FLAG_DOJPHIDE; break; default: usage(); exit(1); } break; default: usage(); exit(1); } argc -= optind; argv += optind; if (argc != 2) { usage(); exit(1); } setvbuf(stdout, NULL, _IOLBF, 0); docompare(argv[0], argv[1]); exit(0); }
int main( int argc, char **argv ) { int rc, optind; LDAP *ld1, *ld2; #ifdef notdef #ifdef HPUX11 #ifndef __LP64__ _main( argc, argv); #endif /* __LP64_ */ #endif /* HPUX11 */ #endif deref = LDAP_DEREF_NEVER; allow_binary = vals2tmp = attrsonly = 0; ldif = 1; sizelimit = timelimit = 0; scope = LDAP_SCOPE_SUBTREE; optind = ldaptool_process_args( argc, argv, "Bb:l:s:z:", 1, options_callback ); if ( optind == -1 ) { usage(); } if ( base == NULL ) { if (( base = getenv( "LDAP_BASEDN" )) == NULL ) { usage(); } } ld1 = ldaptool_ldap_init( 0 ); ldap_set_option( ld1, LDAP_OPT_DEREF, &deref ); ldap_set_option( ld1, LDAP_OPT_TIMELIMIT, &timelimit ); ldap_set_option( ld1, LDAP_OPT_SIZELIMIT, &sizelimit ); ldaptool_bind( ld1 ); ld2 = ldaptool_ldap_init( 1 ); ldap_set_option( ld2, LDAP_OPT_DEREF, &deref ); ldap_set_option( ld2, LDAP_OPT_TIMELIMIT, &timelimit ); ldap_set_option( ld2, LDAP_OPT_SIZELIMIT, &sizelimit ); ldaptool_bind( ld2 ); if ( ldaptool_verbose ) { printf( "Connections to servers established. Beginning comparison.\n" ); } rc = docompare( ld1, ld2, base ); ldaptool_cleanup( ld1 ); ldaptool_cleanup( ld2 ); if ( ldaptool_verbose && !rc ) { if ( !differ ) { printf( "compare completed: no differences found\n" ); } else { printf( "compare completed: ****differences were found****\n" ); } } /* check for and report output error */ fflush( stdout ); rc = ldaptool_check_ferror( stdout, rc, "output error (output might be incomplete)" ); return( rc ); }
int main( int argc, char **argv ) { char *compdn = NULL, *attrs = NULL; char *sep; int rc; LDAP *ld = NULL; struct berval bvalue = { 0, NULL }; int i = 0; LDAPControl c[1]; tool_init( TOOL_COMPARE ); prog = lutil_progname( "ldapcompare", argc, argv ); tool_args( argc, argv ); if ( argc - optind != 2 ) { usage(); } compdn = argv[optind++]; attrs = argv[optind++]; /* user passed in only 2 args, the last one better be in * the form attr:value or attr::b64value */ sep = strchr(attrs, ':'); if (!sep) { usage(); } *sep++='\0'; if ( *sep != ':' ) { bvalue.bv_val = strdup( sep ); bvalue.bv_len = strlen( bvalue.bv_val ); } else { /* it's base64 encoded. */ bvalue.bv_val = malloc( strlen( &sep[1] )); bvalue.bv_len = lutil_b64_pton( &sep[1], (unsigned char *) bvalue.bv_val, strlen( &sep[1] )); if (bvalue.bv_len == (ber_len_t)-1) { fprintf(stderr, _("base64 decode error\n")); exit(-1); } } ld = tool_conn_setup( 0, 0 ); tool_bind( ld ); if ( 0 #ifdef LDAP_CONTROL_DONTUSECOPY || dontUseCopy #endif ) { #ifdef LDAP_CONTROL_DONTUSECOPY if ( dontUseCopy ) { c[i].ldctl_oid = LDAP_CONTROL_DONTUSECOPY; c[i].ldctl_value.bv_val = NULL; c[i].ldctl_value.bv_len = 0; c[i].ldctl_iscritical = dontUseCopy > 1; i++; } #endif } tool_server_controls( ld, c, i ); if ( verbose ) { fprintf( stderr, _("DN:%s, attr:%s, value:%s\n"), compdn, attrs, sep ); } rc = docompare( ld, compdn, attrs, &bvalue, quiet, NULL, NULL ); free( bvalue.bv_val ); tool_exit( ld, rc ); }