BIO_s_mem() Uses MEM_BUF *; the pointer is actually kept in BIO->ptr. This source/sink is bi-directional and should not return errors other than 0 bytes left. Any errors are due to malloc() failures. Normal setup is just bio=BIO_new(BIO_s_men()); BIO_gets does a fgets. BIO_puts does a BIO_put(). /* woops, the folowing need to be fixed :-) */ BIO_CTRL_RESET does a fseek() back to the start of the file. BIO_CTRL_EOF does a feof(). BIO_CTRL_INFO does a ftell(). BIO_CTRL_SET assigned the FILE * and close flag. BIO_CTRL_GET returns the FILE * via the ptr parameter (FILE **). BIO_CTRL_GET_CLOSE/BIO_CTRL_SET_CLOSE returns and sets the close on free flag. BIO_CTRL_PUSH returns 0, does nothing. BIO_CTRL_POP returns 0, does nothing. BIO_CTRL_PENDING unimplemented, returns 0. BIO_CTRL_FLUSH fflush()es the FILE *. BIO_CTRL_SHOULD_RETRY/BIO_CTRL_RETRY_TYPE unimplemented, returns 0. BIO_CTRL_SET_FILENAME is a special case. The file name is opened and used. This is a special case. .