本文整理汇总了C++中sk_push函数的典型用法代码示例。如果您正苦于以下问题:C++ sk_push函数的具体用法?C++ sk_push怎么用?C++ sk_push使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sk_push函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CRYPTO_get_new_lockid
int CRYPTO_get_new_lockid(char *name)
{
char *str;
int i;
#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
/* A hack to make Visual C++ 5.0 work correctly when linking as
* a DLL using /MT. Without this, the application cannot use
* and floating point printf's.
* It also seems to be needed for Visual C 1.5 (win16) */
SSLeay_MSVC5_hack=(double)name[0]*(double)name[1];
#endif
if ((app_locks == NULL) && ((app_locks=sk_new_null()) == NULL))
{
CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
return(0);
}
if ((str=BUF_strdup(name)) == NULL)
{
CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
return(0);
}
i=sk_push(app_locks,str);
if (!i)
OPENSSL_free(str);
else
i+=CRYPTO_NUM_LOCKS; /* gap of one :-) */
return(i);
}
示例2: st_malloc
void* st_malloc(size_t s){
void *temp;
if(st_mem == NULL) sk_init(&st_mem);
temp = malloc(s);
if(sk_push(&st_mem, temp) == 0) fatal(STR_OUT_OF_MEMORY);
return temp;
}
示例3: dl_load
static int dl_load(DSO *dso, const char *filename)
{
shl_t ptr;
char translated[DSO_MAX_TRANSLATED_SIZE];
int len;
/* The same comment as in dlfcn_load applies here. bleurgh. */
len = strlen(filename) + strlen(extension);
if((dso->flags & DSO_FLAG_NAME_TRANSLATION) &&
(len + 3 < DSO_MAX_TRANSLATED_SIZE) &&
(strstr(filename, "/") == NULL))
{
sprintf(translated, "lib%s%s", filename, extension);
ptr = shl_load(translated, BIND_IMMEDIATE, NULL);
}
else
ptr = shl_load(filename, BIND_IMMEDIATE, NULL);
if(ptr == NULL)
{
DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED);
return(0);
}
if(!sk_push(dso->meth_data, (char *)ptr))
{
DSOerr(DSO_F_DL_LOAD,DSO_R_STACK_ERROR);
shl_unload(ptr);
return(0);
}
return(1);
}
示例4: EAC_CTX_init_pace
int
EAC_CTX_init_pace(EAC_CTX *ctx, int protocol, int curve)
{
PACE_CTX *pace_ctx = NULL;
int r = 0;
if (!ctx) {
log_err("Invalid arguments");
goto err;
}
pace_ctx = PACE_CTX_new();
if (!pace_ctx
|| !PACE_CTX_set_protocol(pace_ctx, protocol, ctx->tr_version)
|| !EVP_PKEY_set_std_dp(pace_ctx->static_key, curve)) {
log_err("Could not initialize PACE context");
goto err;
}
r = 1;
err:
if (r && sk_push((_STACK *) ctx->pace_ctxs, pace_ctx)) {
ctx->pace_ctx = pace_ctx;
} else {
/* either an error occurred before
* or we could not push it onto the stack */
r = 0;
PACE_CTX_clear_free(pace_ctx);
}
return r;
}
示例5: dlfcn_load
static int dlfcn_load(DSO *dso)
{
void *ptr = NULL;
/* See applicable comments in dso_dl.c */
char *filename = DSO_convert_filename(dso, NULL);
if(filename == NULL)
{
DSOerr(DSO_F_DLFCN_LOAD,DSO_R_NO_FILENAME);
goto err;
}
ptr = dlopen(filename, DLOPEN_FLAG);
if(ptr == NULL)
{
DSOerr(DSO_F_DLFCN_LOAD,DSO_R_LOAD_FAILED);
ERR_add_error_data(4, "filename(", filename, "): ", dlerror());
goto err;
}
if(!sk_push(dso->meth_data, (char *)ptr))
{
DSOerr(DSO_F_DLFCN_LOAD,DSO_R_STACK_ERROR);
goto err;
}
/* Success */
dso->loaded_filename = filename;
return(1);
err:
/* Cleanup! */
if(filename != NULL)
OPENSSL_free(filename);
if(ptr != NULL)
dlclose(ptr);
return(0);
}
示例6: EAC_CTX_init_ca
int
EAC_CTX_init_ca(EAC_CTX *ctx, int protocol, int curve)
{
CA_CTX *ca_ctx = NULL;
int r = 0;
if (!ctx || !ctx->ca_ctxs) {
log_err("Invalid arguments");
goto err;
}
ca_ctx = CA_CTX_new();
check(ca_ctx, "Could not create CA context");
if (!CA_CTX_set_protocol(ca_ctx, protocol)
|| !EVP_PKEY_set_std_dp(ca_ctx->ka_ctx->key, curve))
goto err;
r = 1;
err:
if (r && sk_push((_STACK *) ctx->ca_ctxs, ca_ctx)) {
ctx->ca_ctx = ca_ctx;
} else {
/* either an error occurred before
* or we could not push it onto the stack */
r = 0;
CA_CTX_clear_free(ca_ctx);
}
return r;
}
示例7: beos_load
static int beos_load (DSO * dso)
{
image_id id;
/* See applicable comments from dso_dl.c */
char *filename = DSO_convert_filename (dso, NULL);
if (filename == NULL)
{
DSOerr (DSO_F_BEOS_LOAD, DSO_R_NO_FILENAME);
goto err;
}
id = load_add_on (filename);
if (id < 1)
{
DSOerr (DSO_F_BEOS_LOAD, DSO_R_LOAD_FAILED);
ERR_add_error_data (3, "filename(", filename, ")");
goto err;
}
if (!sk_push (dso->meth_data, (char *) id))
{
DSOerr (DSO_F_BEOS_LOAD, DSO_R_STACK_ERROR);
goto err;
}
/* Success */
dso->loaded_filename = filename;
return (1);
err:
/* Cleanup ! */
if (filename != NULL)
OPENSSL_free (filename);
if (id > 0)
unload_add_on (id);
return (0);
}
示例8: win32_unload
static int win32_unload(DSO *dso)
{
HINSTANCE *p;
if(dso == NULL)
{
DSOerr(DSO_F_WIN32_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
return(0);
}
if(sk_num(dso->meth_data) < 1)
return(1);
p = (HINSTANCE *)sk_pop(dso->meth_data);
if(p == NULL)
{
DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_NULL_HANDLE);
return(0);
}
if(!FreeLibrary(*p))
{
DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_UNLOAD_FAILED);
/* We should push the value back onto the stack in
* case of a retry. */
sk_push(dso->meth_data, (char *)p);
return(0);
}
/* Cleanup */
OPENSSL_free(p);
return(1);
}
示例9: beos_unload
static int beos_unload (DSO * dso)
{
image_id id;
if (dso == NULL)
{
DSOerr (DSO_F_BEOS_UNLOAD, ERR_R_PASSED_NULL_PARAMETER);
return (0);
}
if (sk_num (dso->meth_data) < 1)
return (1);
id = (image_id) sk_pop (dso->meth_data);
if (id < 1)
{
DSOerr (DSO_F_BEOS_UNLOAD, DSO_R_NULL_HANDLE);
return (0);
}
if (unload_add_on (id) != B_OK)
{
DSOerr (DSO_F_BEOS_UNLOAD, DSO_R_UNLOAD_FAILED);
/* We should push the value back onto the stack in
* case of a retry. */
sk_push (dso->meth_data, (char *) id);
return (0);
}
return (1);
}
示例10: dlfcn_load
static int dlfcn_load(DSO *dso, const char *filename)
{
void *ptr;
char translated[DSO_MAX_TRANSLATED_SIZE];
int len;
/* NB: This is a hideous hack, but I'm not yet sure what
* to replace it with. This attempts to convert any filename,
* that looks like it has no path information, into a
* translated form, e. "blah" -> "libblah.so" */
len = strlen(filename);
if((dso->flags & DSO_FLAG_NAME_TRANSLATION) &&
(len + 6 < DSO_MAX_TRANSLATED_SIZE) &&
(strstr(filename, "/") == NULL))
{
sprintf(translated, "lib%s.so", filename);
ptr = dlopen(translated, DLOPEN_FLAG);
}
else
{
ptr = dlopen(filename, DLOPEN_FLAG);
}
if(ptr == NULL)
{
DSOerr(DSO_F_DLFCN_LOAD,DSO_R_LOAD_FAILED);
return(0);
}
if(!sk_push(dso->meth_data, (char *)ptr))
{
DSOerr(DSO_F_DLFCN_LOAD,DSO_R_STACK_ERROR);
dlclose(ptr);
return(0);
}
return(1);
}
示例11: store
/* The list functions may be the hardest to understand. Basically,
mem_list_start compiles a stack of attribute info elements, and
puts that stack into the context to be returned. mem_list_next
will then find the first matching element in the store, and then
walk all the way to the end of the store (since any combination
of attribute bits above the starting point may match the searched
for bit pattern...). */
static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type,
OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[])
{
struct mem_ctx_st *context =
(struct mem_ctx_st *)OPENSSL_malloc(sizeof(struct mem_ctx_st));
void *attribute_context = NULL;
STORE_ATTR_INFO *attrs = NULL;
if (!context)
{
STOREerr(STORE_F_MEM_LIST_START, ERR_R_MALLOC_FAILURE);
return 0;
}
memset(context, 0, sizeof(struct mem_ctx_st));
attribute_context = STORE_parse_attrs_start(attributes);
if (!attribute_context)
{
STOREerr(STORE_F_MEM_LIST_START, ERR_R_STORE_LIB);
goto err;
}
while((attrs = STORE_parse_attrs_next(attribute_context)))
{
if (context->search_attributes == NULL)
{
context->search_attributes =
sk_new((int (*)(const char * const *, const char * const *))STORE_ATTR_INFO_compare);
if (!context->search_attributes)
{
STOREerr(STORE_F_MEM_LIST_START,
ERR_R_MALLOC_FAILURE);
goto err;
}
}
sk_push(context->search_attributes,(char *)attrs);
}
if (!STORE_parse_attrs_endp(attribute_context))
goto err;
STORE_parse_attrs_end(attribute_context);
context->search_index = -1;
context->index = -1;
return context;
err:
if (attribute_context) STORE_parse_attrs_end(attribute_context);
mem_list_end(s, context);
return NULL;
}
示例12: EVP_PBE_alg_add
int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
EVP_PBE_KEYGEN *keygen)
{
EVP_PBE_CTL *pbe_tmp;
if (!pbe_algs) pbe_algs = sk_new(pbe_cmp);
if (!(pbe_tmp = (EVP_PBE_CTL*) OPENSSL_malloc (sizeof(EVP_PBE_CTL)))) {
EVPerr(EVP_F_EVP_PBE_ALG_ADD,ERR_R_MALLOC_FAILURE);
return 0;
}
pbe_tmp->pbe_nid = nid;
pbe_tmp->cipher = cipher;
pbe_tmp->md = md;
pbe_tmp->keygen = keygen;
sk_push (pbe_algs, (char *)pbe_tmp);
return 1;
}
示例13: win32_load
static int win32_load(DSO *dso)
{
HINSTANCE h = NULL, *p = NULL;
/* See applicable comments from dso_dl.c */
char *filename = DSO_convert_filename(dso, NULL);
if(filename == NULL)
{
DSOerr(DSO_F_WIN32_LOAD,DSO_R_NO_FILENAME);
goto err;
}
h = LoadLibrary(filename);
if(h == NULL)
{
DSOerr(DSO_F_WIN32_LOAD,DSO_R_LOAD_FAILED);
ERR_add_error_data(3, "filename(", filename, ")");
goto err;
}
p = (HINSTANCE *)OPENSSL_malloc(sizeof(HINSTANCE));
if(p == NULL)
{
DSOerr(DSO_F_WIN32_LOAD,ERR_R_MALLOC_FAILURE);
goto err;
}
*p = h;
if(!sk_push(dso->meth_data, (char *)p))
{
DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR);
goto err;
}
/* Success */
dso->loaded_filename = filename;
return(1);
err:
/* Cleanup !*/
if(filename != NULL)
OPENSSL_free(filename);
if(p != NULL)
OPENSSL_free(p);
if(h != NULL)
FreeLibrary(h);
return(0);
}
示例14: EAC_CTX_init_ri
int
EAC_CTX_init_ri(EAC_CTX *ctx, int protocol, int stnd_dp)
{
BUF_MEM *pubkey = NULL;
RI_CTX *ri_ctx = NULL;
int r = 0;
if (!ctx || !ctx->ri_ctxs) {
log_err("Invalid arguments");
goto err;
}
ri_ctx = RI_CTX_new();
check(ri_ctx, "Could not create RI context");
if (!RI_CTX_set_protocol(ri_ctx, protocol)
|| !EVP_PKEY_set_std_dp(ri_ctx->static_key, stnd_dp))
goto err;
if (!ri_ctx->generate_key)
goto err;
pubkey = ri_ctx->generate_key(ri_ctx->static_key, ctx->bn_ctx);
if (!pubkey)
goto err;
else /* We do not need the buffered public key and throw it away immediately */
BUF_MEM_clear_free(pubkey);
r = 1;
err:
if (r && sk_push((_STACK *) ctx->ri_ctxs, ri_ctx)) {
ctx->ri_ctx = ri_ctx;
} else {
/* either an error occurred before
* or we could not push it onto the stack */
r = 0;
RI_CTX_clear_free(ri_ctx);
}
return r;
}
示例15: dl_load
static int dl_load(DSO *dso)
{
shl_t ptr = NULL;
/*
* We don't do any fancy retries or anything, just take the method's (or
* DSO's if it has the callback set) best translation of the
* platform-independent filename and try once with that.
*/
char *filename = DSO_convert_filename(dso, NULL);
if (filename == NULL) {
DSOerr(DSO_F_DL_LOAD, DSO_R_NO_FILENAME);
goto err;
}
ptr = shl_load(filename, BIND_IMMEDIATE |
(dso->flags & DSO_FLAG_NO_NAME_TRANSLATION ? 0 :
DYNAMIC_PATH), 0L);
if (ptr == NULL) {
char errbuf[160];
DSOerr(DSO_F_DL_LOAD, DSO_R_LOAD_FAILED);
if (openssl_strerror_r(errno, errbuf, sizeof(errbuf)))
ERR_add_error_data(4, "filename(", filename, "): ", errbuf);
goto err;
}
if (!sk_push(dso->meth_data, (char *)ptr)) {
DSOerr(DSO_F_DL_LOAD, DSO_R_STACK_ERROR);
goto err;
}
/*
* Success, stick the converted filename we've loaded under into the DSO
* (it also serves as the indicator that we are currently loaded).
*/
dso->loaded_filename = filename;
return (1);
err:
/* Cleanup! */
OPENSSL_free(filename);
if (ptr != NULL)
shl_unload(ptr);
return (0);
}