Manual Pages for UNIX Darwin command on man BIO_set_mem_eof_return
MyWebUniversity

Manual Pages for UNIX Darwin command on man BIO_set_mem_eof_return

BIOsmem(3) OpenSSL BIOsmem(3)

NAME

BIOsmem, BIOsetmemeofreturn, BIOgetmemdata, BIOsetmembuf,

BIOgetmemptr, BIOnewmembuf - memory BIO

SYNOPSIS

#include

BIOMETHOD * BIOsmem(void); BIOsetmemeofreturn(BIO *b,int v) long BIOgetmemdata(BIO *b, char **pp) BIOsetmembuf(BIO *b,BUFMEM *bm,int c) BIOgetmemptr(BIO *b,BUFMEM **pp) BIO *BIOnewmembuf(void *buf, int len);

DESCRIPTION

BIOsmem() return the memory BIO method function. A memory BIO is a source/sink BIO which uses memory for its I/O. Data written to a memory BIO is stored in a BUFMEM structure which is extended as appropriate to accommodate the stored data. Any data written to a memory BIO can be recalled by reading from it. Unless the memory BIO is read only any data read from it is deleted from the BIO. Memory BIOs support BIOgets() and BIOputs(). If the BIOCLOSE flag is set when a memory BIO is freed then the underlying BUFMEM structure is also freed. Calling BIOreset() on a read write memory BIO clears any data in it. On a read only BIO it restores the BIO to its original state and the read only data can be read again. BIOeof() is true if no data is in the BIO. BIOctrlpending() returns the number of bytes currently stored. BIOsetmemeofreturn() sets the behaviour of memory BIO bb when it is empty. If the vv is zero then an empty memory BIO will return EOF (that is it will return zero and BIOshouldretry(b) will be false. If vv is non zero then it will return vv when it is empty and it will set the read retry flag (that is BIOreadretry(b) is true). To avoid ambiguity with a normal positive return value vv should be set to a negative

value, typically -1.

BIOgetmemdata() sets pppp to a pointer to the start of the memory BIOs data and returns the total amount of data available. It is implemented as a macro. BIOsetmembuf() sets the internal BUFMEM structure to bbmm and sets the close flag to cc, that is cc should be either BIOCLOSE or BIONOCLOSE. It is a macro. BIOgetmemptr() places the underlying BUFMEM structure in pppp. It is a macro. BIOnewmembuf() creates a memory BIO using lleenn bytes of data at bbuuff,

if lleenn is -1 then the bbuuff is assumed to be null terminated and its

length is determined by ssttrrlleenn. The BIO is set to a read only state and as a result cannot be written to. This is useful when some data needs to be made available from a static area of memory in the form of a BIO. The supplied data is read directly from the supplied buffer: it is nnoott copied first, so the supplied area of memory must be unchanged until the BIO is freed. NNOOTTEESS Writes to memory BIOs will always succeed if memory is available: that is their size can grow indefinitely. Every read from a read write memory BIO will remove the data just read with an internal copy operation, if a BIO contains a lots of data and it is read in small chunks the operation can be very slow. The use of a read only memory BIO avoids this problem. If the BIO must be read write then adding a buffering BIO to the chain will speed up the process.

BUGS

There should be an option to set the maximum size of a memory BIO. There should be a way to "rewind" a read write BIO without destroying its contents. The copying operation should not occur after every small read of a large BIO to improve efficiency. EEXXAAMMPPLLEE Create a memory BIO and write some data to it: BIO *mem = BIOnew(BIOsmem()); BIOputs(mem, "Hello World\n"); Create a read only memory BIO: char data[] = "Hello World"; BIO *mem;

mem = BIOnewmembuf(data, -1);

Extract the BUFMEM structure from a memory BIO and then free up the BIO: BUFMEM *bptr; BIOgetmemptr(mem, &bptr); BIOsetclose(mem, BIONOCLOSE); /* So BIOfree() leaves BUFMEM alone */ BIOfree(mem);

SEE ALSO

TBA

0.9.7l 2000-09-16 BIOsmem(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™