bm->length = bm->max;
static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)	{	long ret=1;	char **pptr;	BUF_MEM *bm=(BUF_MEM *)b->ptr;	switch (cmd)		{	case BIO_CTRL_RESET:		if (bm->data != NULL) {			/* For read only case reset to the start again */			if(b->flags & BIO_FLAGS_MEM_RDONLY) 					bm->data -= bm->max - bm->length;			else {				memset(bm->data,0,bm->max);				bm->length=0;			}		}		break;	case BIO_CTRL_EOF:		ret=(long)(bm->length == 0);		break;	case BIO_C_SET_BUF_MEM_EOF_RETURN:		b->num=(int)num;		break;	case BIO_CTRL_INFO:		ret=(long)bm->length;		if (ptr != NULL)			{			pptr=(char **)ptr;			*pptr=(char *)&(bm->data[0]);			}		break;	case BIO_C_SET_BUF_MEM:		mem_free(b);		b->shutdown=(int)num;		b->ptr=ptr;		break;	case BIO_C_GET_BUF_MEM_PTR:		if (ptr != NULL)			{			pptr=(char **)ptr;			*pptr=(char *)bm;			}		break;	case BIO_CTRL_GET_CLOSE:		ret=(long)b->shutdown;		break;	case BIO_CTRL_SET_CLOSE:		b->shutdown=(int)num;		break;	case BIO_CTRL_WPENDING:		ret=0L;		break;	case BIO_CTRL_PENDING:		ret=(long)bm->length;		break;	case BIO_CTRL_DUP:	case BIO_CTRL_FLUSH:		ret=1;		break;	case BIO_CTRL_PUSH:	case BIO_CTRL_POP:	default:		ret=0;		break;		}	return(ret);	}