if (!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM)) X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
if (CApath) { i=X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM); if(!i) { BIO_printf(bio_err, "Error loading directory %s\n", CApath); ERR_print_errors(bio_err); goto end; } } else X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
int MAIN(int argc, char **argv)	{	int i,ret=1;	char *CApath=NULL,*CAfile=NULL;	X509_STORE *cert_ctx=NULL;	X509_LOOKUP *lookup=NULL;	cert_ctx=X509_STORE_new();	if (cert_ctx == NULL) goto end;	X509_STORE_set_verify_cb_func(cert_ctx,cb);	ERR_load_crypto_strings();	apps_startup();	if (bio_err == NULL)		if ((bio_err=BIO_new(BIO_s_file())) != NULL)			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);	argc--;	argv++;	for (;;)		{		if (argc >= 1)			{			if (strcmp(*argv,"-CApath") == 0)				{				if (argc-- < 1) goto end;				CApath= *(++argv);				}			else if (strcmp(*argv,"-CAfile") == 0)				{				if (argc-- < 1) goto end;				CAfile= *(++argv);				}			else if (strcmp(*argv,"-help") == 0)				goto end;			else if (strcmp(*argv,"-verbose") == 0)				v_verbose=1;			else if (argv[0][0] == '-')				goto end;			else				break;			argc--;			argv++;			}		else			break;		}	lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_file());	if (lookup == NULL) abort();	if (!X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM))		X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);			lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_hash_dir());	if (lookup == NULL) abort();	if (!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM))		X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);	ERR_clear_error();	if (argc < 1) check(cert_ctx,NULL);	else		for (i=0; i<argc; i++)			check(cert_ctx,argv[i]);	ret=0;end:	if (ret == 1)		BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] cert1 cert2 ...\n");	if (cert_ctx != NULL) X509_STORE_free(cert_ctx);	EXIT(ret);	}