⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bio_s_mem.pod

📁 开源的ssl算法openssl,版本0.9.8H
💻 POD
字号:
=pod=head1 NAMEBIO_s_mem, BIO_set_mem_eof_return, BIO_get_mem_data, BIO_set_mem_buf,BIO_get_mem_ptr, BIO_new_mem_buf - memory BIO=head1 SYNOPSIS #include <openssl/bio.h> BIO_METHOD *	BIO_s_mem(void); BIO_set_mem_eof_return(BIO *b,int v) long BIO_get_mem_data(BIO *b, char **pp) BIO_set_mem_buf(BIO *b,BUF_MEM *bm,int c) BIO_get_mem_ptr(BIO *b,BUF_MEM **pp) BIO *BIO_new_mem_buf(void *buf, int len);=head1 DESCRIPTIONBIO_s_mem() return the memory BIO method function. A memory BIO is a source/sink BIO which uses memory for its I/O. Datawritten to a memory BIO is stored in a BUF_MEM structure which is extendedas 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 fromthe BIO.Memory BIOs support BIO_gets() and BIO_puts().If the BIO_CLOSE flag is set when a memory BIO is freed then the underlyingBUF_MEM structure is also freed.Calling BIO_reset() on a read write memory BIO clears any data in it. On aread only BIO it restores the BIO to its original state and the read onlydata can be read again.BIO_eof() is true if no data is in the BIO.BIO_ctrl_pending() returns the number of bytes currently stored.BIO_set_mem_eof_return() sets the behaviour of memory BIO B<b> when it isempty. If the B<v> is zero then an empty memory BIO will return EOF (that isit will return zero and BIO_should_retry(b) will be false. If B<v> is nonzero then it will return B<v> when it is empty and it will set the read retryflag (that is BIO_read_retry(b) is true). To avoid ambiguity with a normalpositive return value B<v> should be set to a negative value, typically -1.BIO_get_mem_data() sets B<pp> to a pointer to the start of the memory BIOs dataand returns the total amount of data available. It is implemented as a macro.BIO_set_mem_buf() sets the internal BUF_MEM structure to B<bm> and sets theclose flag to B<c>, that is B<c> should be either BIO_CLOSE or BIO_NOCLOSE.It is a macro.BIO_get_mem_ptr() places the underlying BUF_MEM structure in B<pp>. It isa macro.BIO_new_mem_buf() creates a memory BIO using B<len> bytes of data at B<buf>,if B<len> is -1 then the B<buf> is assumed to be null terminated and itslength is determined by B<strlen>. The BIO is set to a read only state andas a result cannot be written to. This is useful when some data needs to bemade available from a static area of memory in the form of a BIO. Thesupplied data is read directly from the supplied buffer: it is B<not> copiedfirst, so the supplied area of memory must be unchanged until the BIO is freed.=head1 NOTESWrites to memory BIOs will always succeed if memory is available: that istheir size can grow indefinitely.Every read from a read write memory BIO will remove the data just read withan internal copy operation, if a BIO contains a lots of data and it isread in small chunks the operation can be very slow. The use of a read onlymemory BIO avoids this problem. If the BIO must be read write then addinga buffering BIO to the chain will speed up the process.=head1 BUGSThere 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 destroyingits contents.The copying operation should not occur after every small read of a large BIOto improve efficiency.=head1 EXAMPLECreate a memory BIO and write some data to it: BIO *mem = BIO_new(BIO_s_mem()); BIO_puts(mem, "Hello World\n"); Create a read only memory BIO: char data[] = "Hello World"; BIO *mem; mem = BIO_new_mem_buf(data, -1);Extract the BUF_MEM structure from a memory BIO and then free up the BIO: BUF_MEM *bptr; BIO_get_mem_ptr(mem, &bptr); BIO_set_close(mem, BIO_NOCLOSE); /* So BIO_free() leaves BUF_MEM alone */ BIO_free(mem); =head1 SEE ALSOTBA

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -