RSA BSAFE Micro Edition Suite

Streamlined security for mobile and embedded devices

Search  Print

Allocation/Deallocation Functions

This section details the functions used to create, initialize and free BIOs.

Functions

BIO* R_CDECL BIO_new (BIO_METHOD *method)
 Creates a new BIO and associates the method type against the structure. More...

int R_CDECL BIO_new_init (R_LIB_CTX *lib_ctx, int flag, int type, int sub_id, void *value, BIO **bio)
 Creates a new BIO from the method table in the resource list. More...

int R_CDECL BIO_set (BIO *bio, BIO_METHOD *type)
 Associates the BIO_METHOD method against the BIO bio. More...

int R_CDECL BIO_free (BIO *bio)
 Frees the BIO bio. More...

void R_CDECL BIO_free_all (BIO *bio)
 Frees all BIOs in the BIO stack bio. More...


Function Documentation

int R_CDECL BIO_free BIO   bio ;
 

Frees the BIO bio.

Parameters:
bio [In, Out] A reference to the BIO to free.
Returns:
1 indicates success.
<=0 indicates error.
note.gif
BIOs with an underlying file descriptor may or may not close the file descriptor when the BIO is freed. This action depends upon the value of the BIO shutdown flag.
See also:
BIO_new_fp(), BIO_free_all() and BIO_read_filename().
Example:

/* $Id: bio_free.c,v 1.2 2003/05/23 05:20:02 sparki Exp $ */
/*
 * Copyright (C) 1998-2003 RSA Security Inc. All rights reserved. 
 *
 * This work contains proprietary information of RSA Security. 
 * Distribution is limited to authorized licensees of RSA 
 * Security. Any unauthorized reproduction, distribution or 
 * modification of this work is strictly prohibited.
 */
/* Create a memory buffer BIO */ 
bio = BIO_new_mem(); 

/* Use the BIO as required */ 

/* Close the BIO and free its memory */ 
BIO_free (bio); 

bio = NULL; 

Samples:
bio_client.c, bio_server.c, cache_server.c, cert.c, cert_smpl.c, cm.c, cm_adv.c, cm_dgst.c, cm_env.c, cm_env_sm.c, cm_env_strm.c, cm_env_strm_membio.c, cm_open.c, cm_open_strm.c, cm_open_strm_cb.c, cm_open_strm_membio.c, cm_sign.c, cm_sign_dgst.c, cm_sign_sm.c, cm_sign_strm.c, cm_smpl.c, cm_strm.c, cm_type.c, cm_vfy_strm_cb.c, evpkey2rpkey.c, ext.c, frombuf.c, nbio_client.c, nbio_server.c, ocsp_req_create.c, ocsp_req_print.c, ocsp_resp_ext.c, ocsp_resp_find_key.c, ocsp_resp_print.c, ocsp_resp_vfy.c, p7ssl_client.c, p7ssl_server.c, pkey.c, r_asym.c, r_asym_buf.c, r_asym_items.c, r_ciph.c, r_dgst.c, r_gnrt.c, r_hmac.c, r_random.c, r_sign.c, r_version.c, rcert2sslcert.c, req.c, req_smpl.c, reqgen.c, reslist_set.c, s_crl_check.c, s_crl_verify.c, sock_client.c, sock_server.c, ss_cert_smpl.c, ssl_client.c, ssl_server.c, sslcert2rcert.c, store.c, thread.c, verify.c, vfy_adv.c, vfy_bc.c, and vfy_smpl.c.

void R_CDECL BIO_free_all BIO   bio ;
 

Frees all BIOs in the BIO stack bio.

Parameters:
bio [In, Out] A reference to the BIO stack.
See also:
BIO_free().
Example:

/* $Id: bio_free_all.c,v 1.2 2003/05/23 05:20:02 sparki Exp $ */
/*
 * Copyright (C) 1998-2003 RSA Security Inc. All rights reserved. 
 *
 * This work contains proprietary information of RSA Security. 
 * Distribution is limited to authorized licensees of RSA 
 * Security. Any unauthorized reproduction, distribution or 
 * modification of this work is strictly prohibited.
 */
/* bss = BIO_new(BIO_s_null()) */
/* hash = BIO_new(BIO_f_md()) */
/* ... */
/* Form the BIO stack - push hash onto bss */
bio = BIO_push(hash, bss);

/* Use the BIO stack */ 
/* BIO_write(bio,...) */ 

/* Close all BIO's and free their memory */ 
BIO_free_all (bio); 

bio = NULL; 
hash = NULL; 
bss = NULL;

Samples:
bio_client.c, bio_server.c, nbio_client.c, nbio_server.c, and sock_client.c.

BIO* R_CDECL BIO_new BIO_METHOD   method ;
 

Creates a new BIO and associates the method type against the structure. After the method is associated with the BIO, the created method is used.

Parameters:
method [In] A reference to the BIO_METHOD.
Returns:
A reference to the new BIO.
NULL indicates an error during creation. An error message may also be set.
note.gif
The new BIO allocates memory which should be de-allocated via BIO_free() when no longer required.
See also:
BIO_free().
Example:

/* $Id: bio_new.c,v 1.2 2003/05/23 05:20:02 sparki Exp $ */
/*
 * Copyright (C) 1998-2003 RSA Security Inc. All rights reserved. 
 *
 * This work contains proprietary information of RSA Security. 
 * Distribution is limited to authorized licensees of RSA 
 * Security. Any unauthorized reproduction, distribution or 
 * modification of this work is strictly prohibited.
 */
/* type = pointer to BIO_METHOD structure */
bio = BIO_new(type);
if (bio == NULL)
{
    /* Deal with the error condition */
    exit(0);
}

/* Use the bio */

BIO_free(bio);
bio = NULL;

int R_CDECL BIO_new_init R_LIB_CTX   lib_ctx,
int    flag,
int    type,
int    sub_id,
void *    value,
BIO **    bio
;
 

Creates a new BIO from the method table in the resource list.

Parameters:
lib_ctx [In] The library context.
flag [In] The flag indicating scope.
See RES_FLAG for valid values.
type [In] The type of BIO to create.
See BIO_TYPE_DEF for valid values.
sub_id [In] Secondary identifier of BIO type.
value [In] A pointer to type specific data.
bio [Out] The newly created BIO.
Returns:
R_ERROR_NONE indicates success.
See Identifiers for valid values.
See also:
BIO_new() and BIO_free().
Samples:
cm_dgst.c, and cm_sign_dgst.c.

int R_CDECL BIO_set BIO   bio,
BIO_METHOD   method
;
 

Associates the BIO_METHOD method against the BIO bio. After the method is associated with the BIO, this method is used.

Parameters:
bio [In, Out] A reference to the BIO.
method [In] A reference to the BIO_METHOD.
Returns:
1 indicates the method was associated successfully.
0 indicates error.


Copyright (c) 1999-2005 RSA Security Inc. All rights reserved. 072-001001-2100-001-000 - 2.1