int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
				       const char *dir)
	{
	DIR *d;
	struct dirent *dstruct;
	int ret = 0;
	CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
	d = opendir(dir);
	if(!d)
		{
		SYSerr(SYS_F_OPENDIR, get_last_sys_error());
		ERR_add_error_data(3, "opendir('", dir, "')");
		SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB);
		goto err;
		}
	while((dstruct=readdir(d)))
		{
		char buf[1024];
		int r;
		if(strlen(dir)+strlen(dstruct->d_name)+2 > sizeof buf)
			{
			SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG);
			goto err;
			}
		r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name);
		if (r <= 0 || r >= sizeof buf)
			goto err;
		if(!SSL_add_file_cert_subjects_to_stack(stack,buf))
			goto err;
		}
	ret = 1;
err:
	CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
	return ret;
	}
['int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,\n\t\t\t\t       const char *dir)\n\t{\n\tDIR *d;\n\tstruct dirent *dstruct;\n\tint ret = 0;\n\tCRYPTO_w_lock(CRYPTO_LOCK_READDIR);\n\td = opendir(dir);\n\tif(!d)\n\t\t{\n\t\tSYSerr(SYS_F_OPENDIR, get_last_sys_error());\n\t\tERR_add_error_data(3, "opendir(\'", dir, "\')");\n\t\tSSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB);\n\t\tgoto err;\n\t\t}\n\twhile((dstruct=readdir(d)))\n\t\t{\n\t\tchar buf[1024];\n\t\tint r;\n\t\tif(strlen(dir)+strlen(dstruct->d_name)+2 > sizeof buf)\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG);\n\t\t\tgoto err;\n\t\t\t}\n\t\tr = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name);\n\t\tif (r <= 0 || r >= sizeof buf)\n\t\t\tgoto err;\n\t\tif(!SSL_add_file_cert_subjects_to_stack(stack,buf))\n\t\t\tgoto err;\n\t\t}\n\tret = 1;\nerr:\n\tCRYPTO_w_unlock(CRYPTO_LOCK_READDIR);\n\treturn ret;\n\t}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n\t{\n#ifdef LOCK_DEBUG\n\t\t{\n\t\tchar *rw_text,*operation_text;\n\t\tif (mode & CRYPTO_LOCK)\n\t\t\toperation_text="lock  ";\n\t\telse if (mode & CRYPTO_UNLOCK)\n\t\t\toperation_text="unlock";\n\t\telse\n\t\t\toperation_text="ERROR ";\n\t\tif (mode & CRYPTO_READ)\n\t\t\trw_text="r";\n\t\telse if (mode & CRYPTO_WRITE)\n\t\t\trw_text="w";\n\t\telse\n\t\t\trw_text="ERROR";\n\t\tfprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\\n",\n\t\t\tCRYPTO_thread_id(), rw_text, operation_text,\n\t\t\tCRYPTO_get_lock_name(type), file, line);\n\t\t}\n#endif\n\tif (locking_callback != NULL)\n\t\tlocking_callback(mode,type,file,line);\n\t}', 'int BIO_snprintf(char *buf, size_t n, const char *format, ...)\n\t{\n\tva_list args;\n\tsize_t retlen;\n\tint truncated;\n\tva_start(args, format);\n\t_dopr(dopr_outch, dopr_isbig, dopr_copy,\n\t\t&buf, &n, &retlen, &truncated, format, args);\n\tif (truncated)\n\t\treturn -1;\n\telse\n\t\treturn (retlen <= INT_MAX) ? retlen : -1;\n\t}']