static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
			  LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
	{
	int i;
	LHASH_NODE *a,*n;
	if (lh == NULL)
		return;
	for (i=lh->num_nodes-1; i>=0; i--)
		{
		a=lh->b[i];
		while (a != NULL)
			{
			n=a->next;
			if(use_arg)
				func_arg(a->data,arg);
			else
				func(a->data);
			a=n;
			}
		}
	}
['int MAIN(int argc, char **argv)\n\t{\n\tint ret=1,i;\n\tint verbose=0,Verbose=0;\n\tint use_supported = 0;\n#ifndef OPENSSL_NO_SSL_TRACE\n\tint stdname = 0;\n#endif\n\tconst char **pp;\n\tconst char *p;\n\tint badops=0;\n\tSSL_CTX *ctx=NULL;\n\tSSL *ssl=NULL;\n\tchar *ciphers=NULL;\n\tconst SSL_METHOD *meth=NULL;\n\tSTACK_OF(SSL_CIPHER) *sk;\n\tchar buf[512];\n\tBIO *STDout=NULL;\n#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)\n\tmeth=SSLv23_server_method();\n#elif !defined(OPENSSL_NO_SSL3)\n\tmeth=SSLv3_server_method();\n#elif !defined(OPENSSL_NO_SSL2)\n\tmeth=SSLv2_server_method();\n#endif\n\tapps_startup();\n\tif (bio_err == NULL)\n\t\tbio_err=BIO_new_fp(stderr,BIO_NOCLOSE);\n\tSTDout=BIO_new_fp(stdout,BIO_NOCLOSE);\n#ifdef OPENSSL_SYS_VMS\n\t{\n\tBIO *tmpbio = BIO_new(BIO_f_linebuffer());\n\tSTDout = BIO_push(tmpbio, STDout);\n\t}\n#endif\n\tif (!load_config(bio_err, NULL))\n\t\tgoto end;\n\targc--;\n\targv++;\n\twhile (argc >= 1)\n\t\t{\n\t\tif (strcmp(*argv,"-v") == 0)\n\t\t\tverbose=1;\n\t\telse if (strcmp(*argv,"-V") == 0)\n\t\t\tverbose=Verbose=1;\n\t\telse if (strcmp(*argv,"-s") == 0)\n\t\t\tuse_supported = 1;\n#ifndef OPENSSL_NO_SSL_TRACE\n\t\telse if (strcmp(*argv,"-stdname") == 0)\n\t\t\tstdname=verbose=1;\n#endif\n#ifndef OPENSSL_NO_SSL2\n\t\telse if (strcmp(*argv,"-ssl2") == 0)\n\t\t\tmeth=SSLv2_client_method();\n#endif\n#ifndef OPENSSL_NO_SSL3\n\t\telse if (strcmp(*argv,"-ssl3") == 0)\n\t\t\tmeth=SSLv3_client_method();\n#endif\n#ifndef OPENSSL_NO_TLS1\n\t\telse if (strcmp(*argv,"-tls1") == 0)\n\t\t\tmeth=TLSv1_client_method();\n#endif\n\t\telse if ((strncmp(*argv,"-h",2) == 0) ||\n\t\t\t (strcmp(*argv,"-?") == 0))\n\t\t\t{\n\t\t\tbadops=1;\n\t\t\tbreak;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tciphers= *argv;\n\t\t\t}\n\t\targc--;\n\t\targv++;\n\t\t}\n\tif (badops)\n\t\t{\n\t\tfor (pp=ciphers_usage; (*pp != NULL); pp++)\n\t\t\tBIO_printf(bio_err,"%s",*pp);\n\t\tgoto end;\n\t\t}\n\tOpenSSL_add_ssl_algorithms();\n\tctx=SSL_CTX_new(meth);\n\tif (ctx == NULL) goto err;\n\tif (ciphers != NULL) {\n\t\tif(!SSL_CTX_set_cipher_list(ctx,ciphers)) {\n\t\t\tBIO_printf(bio_err, "Error in cipher list\\n");\n\t\t\tgoto err;\n\t\t}\n\t}\n\tssl=SSL_new(ctx);\n\tif (ssl == NULL) goto err;\n\tif (use_supported)\n\t\tsk=SSL_get1_supported_ciphers(ssl);\n\telse\n\t\tsk=SSL_get_ciphers(ssl);\n\tif (!verbose)\n\t\t{\n\t\tfor (i=0; i<sk_SSL_CIPHER_num(sk); i++)\n\t\t\t{\n\t\t\tSSL_CIPHER *c = sk_SSL_CIPHER_value(sk,i);\n\t\t\tp = SSL_CIPHER_get_name(c);\n\t\t\tif (p == NULL) break;\n\t\t\tif (i != 0) BIO_printf(STDout,":");\n\t\t\tBIO_printf(STDout,"%s",p);\n\t\t\t}\n\t\tBIO_printf(STDout,"\\n");\n\t\t}\n\telse\n\t\t{\n\t\tfor (i=0; i<sk_SSL_CIPHER_num(sk); i++)\n\t\t\t{\n\t\t\tSSL_CIPHER *c;\n\t\t\tc = sk_SSL_CIPHER_value(sk,i);\n\t\t\tif (Verbose)\n\t\t\t\t{\n\t\t\t\tunsigned long id = SSL_CIPHER_get_id(c);\n\t\t\t\tint id0 = (int)(id >> 24);\n\t\t\t\tint id1 = (int)((id >> 16) & 0xffL);\n\t\t\t\tint id2 = (int)((id >> 8) & 0xffL);\n\t\t\t\tint id3 = (int)(id & 0xffL);\n\t\t\t\tif ((id & 0xff000000L) == 0x02000000L)\n\t\t\t\t\tBIO_printf(STDout, "     0x%02X,0x%02X,0x%02X - ", id1, id2, id3);\n\t\t\t\telse if ((id & 0xff000000L) == 0x03000000L)\n\t\t\t\t\tBIO_printf(STDout, "          0x%02X,0x%02X - ", id2, id3);\n\t\t\t\telse\n\t\t\t\t\tBIO_printf(STDout, "0x%02X,0x%02X,0x%02X,0x%02X - ", id0, id1, id2, id3);\n\t\t\t\t}\n#ifndef OPENSSL_NO_SSL_TRACE\n\t\t\tif (stdname)\n\t\t\t\t{\n\t\t\t\tconst char *nm = SSL_CIPHER_standard_name(c);\n\t\t\t\tif (nm == NULL)\n\t\t\t\t\tnm = "UNKNOWN";\n\t\t\t\tBIO_printf(STDout, "%s - ", nm);\n\t\t\t\t}\n#endif\n\t\t\tBIO_puts(STDout,SSL_CIPHER_description(c,buf,sizeof buf));\n\t\t\t}\n\t\t}\n\tret=0;\n\tif (0)\n\t\t{\nerr:\n\t\tSSL_load_error_strings();\n\t\tERR_print_errors(bio_err);\n\t\t}\nend:\n\tif (use_supported && sk)\n\t\tsk_SSL_CIPHER_free(sk);\n\tif (ctx != NULL) SSL_CTX_free(ctx);\n\tif (ssl != NULL) SSL_free(ssl);\n\tif (STDout != NULL) BIO_free_all(STDout);\n\tapps_shutdown();\n\tOPENSSL_EXIT(ret);\n\t}', 'SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)\n\t{\n\tSSL_CTX *ret=NULL;\n\tif (meth == NULL)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_CTX_NEW,SSL_R_NULL_SSL_METHOD_PASSED);\n\t\treturn(NULL);\n\t\t}\n#ifdef OPENSSL_FIPS\n\tif (FIPS_mode() && (meth->version < TLS1_VERSION))\n\t\t{\n\t\tSSLerr(SSL_F_SSL_CTX_NEW, SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE);\n\t\treturn NULL;\n\t\t}\n#endif\n\tif (SSL_get_ex_data_X509_STORE_CTX_idx() < 0)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_CTX_NEW,SSL_R_X509_VERIFICATION_SETUP_PROBLEMS);\n\t\tgoto err;\n\t\t}\n\tret=(SSL_CTX *)OPENSSL_malloc(sizeof(SSL_CTX));\n\tif (ret == NULL)\n\t\tgoto err;\n\tmemset(ret,0,sizeof(SSL_CTX));\n\tret->method=meth;\n\tret->cert_store=NULL;\n\tret->session_cache_mode=SSL_SESS_CACHE_SERVER;\n\tret->session_cache_size=SSL_SESSION_CACHE_MAX_SIZE_DEFAULT;\n\tret->session_cache_head=NULL;\n\tret->session_cache_tail=NULL;\n\tret->session_timeout=meth->get_timeout();\n\tret->new_session_cb=0;\n\tret->remove_session_cb=0;\n\tret->get_session_cb=0;\n\tret->generate_session_id=0;\n\tmemset((char *)&ret->stats,0,sizeof(ret->stats));\n\tret->references=1;\n\tret->quiet_shutdown=0;\n\tret->info_callback=NULL;\n\tret->app_verify_callback=0;\n\tret->app_verify_arg=NULL;\n\tret->max_cert_list=SSL_MAX_CERT_LIST_DEFAULT;\n\tret->read_ahead=0;\n\tret->msg_callback=0;\n\tret->msg_callback_arg=NULL;\n\tret->verify_mode=SSL_VERIFY_NONE;\n#if 0\n\tret->verify_depth=-1;\n#endif\n\tret->sid_ctx_length=0;\n\tret->default_verify_callback=NULL;\n\tif ((ret->cert=ssl_cert_new()) == NULL)\n\t\tgoto err;\n\tret->default_passwd_callback=0;\n\tret->default_passwd_callback_userdata=NULL;\n\tret->client_cert_cb=0;\n\tret->app_gen_cookie_cb=0;\n\tret->app_verify_cookie_cb=0;\n\tret->sessions=lh_SSL_SESSION_new();\n\tif (ret->sessions == NULL) goto err;\n\tret->cert_store=X509_STORE_new();\n\tif (ret->cert_store == NULL) goto err;\n\tssl_create_cipher_list(ret->method,\n\t\t&ret->cipher_list,&ret->cipher_list_by_id,\n\t\tmeth->version == SSL2_VERSION ? "SSLv2" : SSL_DEFAULT_CIPHER_LIST, ret->cert);\n\tif (ret->cipher_list == NULL\n\t    || sk_SSL_CIPHER_num(ret->cipher_list) <= 0)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_CTX_NEW,SSL_R_LIBRARY_HAS_NO_CIPHERS);\n\t\tgoto err2;\n\t\t}\n\tret->param = X509_VERIFY_PARAM_new();\n\tif (!ret->param)\n\t\tgoto err;\n\tif ((ret->rsa_md5=EVP_get_digestbyname("ssl2-md5")) == NULL)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES);\n\t\tgoto err2;\n\t\t}\n\tif ((ret->md5=EVP_get_digestbyname("ssl3-md5")) == NULL)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES);\n\t\tgoto err2;\n\t\t}\n\tif ((ret->sha1=EVP_get_digestbyname("ssl3-sha1")) == NULL)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES);\n\t\tgoto err2;\n\t\t}\n\tif ((ret->client_CA=sk_X509_NAME_new_null()) == NULL)\n\t\tgoto err;\n\tCRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ret, &ret->ex_data);\n\tret->extra_certs=NULL;\n\tif (!(meth->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS))\n\t\tret->comp_methods=SSL_COMP_get_compression_methods();\n\tret->max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH;\n#ifndef OPENSSL_NO_TLSEXT\n\tret->tlsext_servername_callback = 0;\n\tret->tlsext_servername_arg = NULL;\n\tif ((RAND_pseudo_bytes(ret->tlsext_tick_key_name, 16) <= 0)\n\t\t|| (RAND_bytes(ret->tlsext_tick_hmac_key, 16) <= 0)\n\t\t|| (RAND_bytes(ret->tlsext_tick_aes_key, 16) <= 0))\n\t\tret->options |= SSL_OP_NO_TICKET;\n\tret->tlsext_status_cb = 0;\n\tret->tlsext_status_arg = NULL;\n# ifndef OPENSSL_NO_NEXTPROTONEG\n\tret->next_protos_advertised_cb = 0;\n\tret->next_proto_select_cb = 0;\n# endif\n#endif\n#ifndef OPENSSL_NO_PSK\n\tret->psk_identity_hint=NULL;\n\tret->psk_client_callback=NULL;\n\tret->psk_server_callback=NULL;\n#endif\n#ifndef OPENSSL_NO_SRP\n\tSSL_CTX_SRP_CTX_init(ret);\n#endif\n\tret->custom_cli_ext_records = NULL;\n\tret->custom_cli_ext_records_count = 0;\n\tret->custom_srv_ext_records = NULL;\n\tret->custom_srv_ext_records_count = 0;\n\tret->cli_supp_data_records = NULL;\n\tret->cli_supp_data_records_count = 0;\n\tret->srv_supp_data_records = NULL;\n\tret->srv_supp_data_records_count = 0;\n#ifndef OPENSSL_NO_BUF_FREELISTS\n\tret->freelist_max_len = SSL_MAX_BUF_FREELIST_LEN_DEFAULT;\n\tret->rbuf_freelist = OPENSSL_malloc(sizeof(SSL3_BUF_FREELIST));\n\tif (!ret->rbuf_freelist)\n\t\tgoto err;\n\tret->rbuf_freelist->chunklen = 0;\n\tret->rbuf_freelist->len = 0;\n\tret->rbuf_freelist->head = NULL;\n\tret->wbuf_freelist = OPENSSL_malloc(sizeof(SSL3_BUF_FREELIST));\n\tif (!ret->wbuf_freelist)\n\t\t{\n\t\tOPENSSL_free(ret->rbuf_freelist);\n\t\tgoto err;\n\t\t}\n\tret->wbuf_freelist->chunklen = 0;\n\tret->wbuf_freelist->len = 0;\n\tret->wbuf_freelist->head = NULL;\n#endif\n#ifndef OPENSSL_NO_ENGINE\n\tret->client_cert_engine = NULL;\n#ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO\n#define eng_strx(x)\t#x\n#define eng_str(x)\teng_strx(x)\n\t{\n\tENGINE *eng;\n\teng = ENGINE_by_id(eng_str(OPENSSL_SSL_CLIENT_ENGINE_AUTO));\n\tif (!eng)\n\t\t{\n\t\tERR_clear_error();\n\t\tENGINE_load_builtin_engines();\n\t\teng = ENGINE_by_id(eng_str(OPENSSL_SSL_CLIENT_ENGINE_AUTO));\n\t\t}\n\tif (!eng || !SSL_CTX_set_client_cert_engine(ret, eng))\n\t\tERR_clear_error();\n\t}\n#endif\n#endif\n\tret->options |= SSL_OP_LEGACY_SERVER_CONNECT;\n\treturn(ret);\nerr:\n\tSSLerr(SSL_F_SSL_CTX_NEW,ERR_R_MALLOC_FAILURE);\nerr2:\n\tif (ret != NULL) SSL_CTX_free(ret);\n\treturn(NULL);\n\t}', '_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c)\n\t{\n\t_LHASH *ret;\n\tint i;\n\tif ((ret=OPENSSL_malloc(sizeof(_LHASH))) == NULL)\n\t\tgoto err0;\n\tif ((ret->b=OPENSSL_malloc(sizeof(LHASH_NODE *)*MIN_NODES)) == NULL)\n\t\tgoto err1;\n\tfor (i=0; i<MIN_NODES; i++)\n\t\tret->b[i]=NULL;\n\tret->comp=((c == NULL)?(LHASH_COMP_FN_TYPE)strcmp:c);\n\tret->hash=((h == NULL)?(LHASH_HASH_FN_TYPE)lh_strhash:h);\n\tret->num_nodes=MIN_NODES/2;\n\tret->num_alloc_nodes=MIN_NODES;\n\tret->p=0;\n\tret->pmax=MIN_NODES/2;\n\tret->up_load=UP_LOAD;\n\tret->down_load=DOWN_LOAD;\n\tret->num_items=0;\n\tret->num_expands=0;\n\tret->num_expand_reallocs=0;\n\tret->num_contracts=0;\n\tret->num_contract_reallocs=0;\n\tret->num_hash_calls=0;\n\tret->num_comp_calls=0;\n\tret->num_insert=0;\n\tret->num_replace=0;\n\tret->num_delete=0;\n\tret->num_no_delete=0;\n\tret->num_retrieve=0;\n\tret->num_retrieve_miss=0;\n\tret->num_hash_comps=0;\n\tret->error=0;\n\treturn(ret);\nerr1:\n\tOPENSSL_free(ret);\nerr0:\n\treturn(NULL);\n\t}', 'void SSL_CTX_free(SSL_CTX *a)\n\t{\n\tint i;\n\tif (a == NULL) return;\n\ti=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_SSL_CTX);\n#ifdef REF_PRINT\n\tREF_PRINT("SSL_CTX",a);\n#endif\n\tif (i > 0) return;\n#ifdef REF_CHECK\n\tif (i < 0)\n\t\t{\n\t\tfprintf(stderr,"SSL_CTX_free, bad reference count\\n");\n\t\tabort();\n\t\t}\n#endif\n\tif (a->param)\n\t\tX509_VERIFY_PARAM_free(a->param);\n\tif (a->sessions != NULL)\n\t\tSSL_CTX_flush_sessions(a,0);\n\tCRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);\n\tif (a->sessions != NULL)\n\t\tlh_SSL_SESSION_free(a->sessions);\n\tif (a->cert_store != NULL)\n\t\tX509_STORE_free(a->cert_store);\n\tif (a->cipher_list != NULL)\n\t\tsk_SSL_CIPHER_free(a->cipher_list);\n\tif (a->cipher_list_by_id != NULL)\n\t\tsk_SSL_CIPHER_free(a->cipher_list_by_id);\n\tif (a->cert != NULL)\n\t\tssl_cert_free(a->cert);\n\tif (a->client_CA != NULL)\n\t\tsk_X509_NAME_pop_free(a->client_CA,X509_NAME_free);\n\tif (a->extra_certs != NULL)\n\t\tsk_X509_pop_free(a->extra_certs,X509_free);\n#if 0\n\tif (a->comp_methods != NULL)\n\t\tsk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free);\n#else\n\ta->comp_methods = NULL;\n#endif\n        if (a->srtp_profiles)\n                sk_SRTP_PROTECTION_PROFILE_free(a->srtp_profiles);\n#ifndef OPENSSL_NO_PSK\n\tif (a->psk_identity_hint)\n\t\tOPENSSL_free(a->psk_identity_hint);\n#endif\n#ifndef OPENSSL_NO_SRP\n\tSSL_CTX_SRP_CTX_free(a);\n#endif\n#ifndef OPENSSL_NO_TLSEXT\n\tOPENSSL_free(a->custom_cli_ext_records);\n\tOPENSSL_free(a->custom_srv_ext_records);\n\tOPENSSL_free(a->cli_supp_data_records);\n\tOPENSSL_free(a->srv_supp_data_records);\n#endif\n#ifndef OPENSSL_NO_ENGINE\n\tif (a->client_cert_engine)\n\t\tENGINE_finish(a->client_cert_engine);\n#endif\n#ifndef OPENSSL_NO_BUF_FREELISTS\n\tif (a->wbuf_freelist)\n\t\tssl_buf_freelist_free(a->wbuf_freelist);\n\tif (a->rbuf_freelist)\n\t\tssl_buf_freelist_free(a->rbuf_freelist);\n#endif\n#ifndef OPENSSL_NO_TLSEXT\n# ifndef OPENSSL_NO_EC\n\tif (a->tlsext_ecpointformatlist)\n\t\tOPENSSL_free(a->tlsext_ecpointformatlist);\n\tif (a->tlsext_ellipticcurvelist)\n\t\tOPENSSL_free(a->tlsext_ellipticcurvelist);\n# endif\n\tif (a->alpn_client_proto_list != NULL)\n\t\tOPENSSL_free(a->alpn_client_proto_list);\n#endif\n\tOPENSSL_free(a);\n\t}', 'void SSL_CTX_flush_sessions(SSL_CTX *s, long t)\n\t{\n\tunsigned long i;\n\tTIMEOUT_PARAM tp;\n\ttp.ctx=s;\n\ttp.cache=s->sessions;\n\tif (tp.cache == NULL) return;\n\ttp.time=t;\n\tCRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);\n\ti=CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load;\n\tCHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load=0;\n\tlh_SSL_SESSION_doall_arg(tp.cache, LHASH_DOALL_ARG_FN(timeout),\n\t\t\t\t TIMEOUT_PARAM, &tp);\n\tCHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load=i;\n\tCRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);\n\t}', 'void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)\n\t{\n\tdoall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);\n\t}', 'static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,\n\t\t\t  LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)\n\t{\n\tint i;\n\tLHASH_NODE *a,*n;\n\tif (lh == NULL)\n\t\treturn;\n\tfor (i=lh->num_nodes-1; i>=0; i--)\n\t\t{\n\t\ta=lh->b[i];\n\t\twhile (a != NULL)\n\t\t\t{\n\t\t\tn=a->next;\n\t\t\tif(use_arg)\n\t\t\t\tfunc_arg(a->data,arg);\n\t\t\telse\n\t\t\t\tfunc(a->data);\n\t\t\ta=n;\n\t\t\t}\n\t\t}\n\t}']