Esempio n. 1
0
int main(int argc, char **argv)
{
    struct url_table *url = NULL;
    struct md5_table *md5 = NULL;
    int i;

    if (argc != 2) {
        printf("Usage: ./url url_db\n");
        return 1;
    }

    if ((url = load_urldb(argv[1])) == NULL)
        return 2;

    md5 = (struct md5_table*)
        malloc(sizeof(struct md5_table) + sizeof(MD5) * url->num);
    if (md5 == NULL) {
        printf("malloc md5 table failed\n");
        return 3;
    }

    md5->num = url->num;
    for (i = 0; i < url->num; i ++) {
        unsigned char digest[16];
        getHashKey((char *)(url->urls + i), digest);
        memcpy(md5->key + i, digest, sizeof(MD5));
    }

    algorithm_init(md5);
    algorithm_test(md5);

    free(url);
    free(md5);
    return 0;
}
Esempio n. 2
0
// Main program.
int main(int argc, char *argv[]) {
	// Command line parsing
	commandline_init();
	commandline_option_register("-b", "--binary", cCommandLine_Option);
	commandline_parse(argc, argv);

	// Help
	if (commandline_option_provided("-h", "--help")) {
		help();
		exit(1);
	}

	// Initialization
	algorithm_init();

	// Run
	algorithm_run();
	return 0;
}