64 static int mem_write(
BIO *
h,
const char *buf,
int num);
65 static int mem_read(
BIO *
h,
char *buf,
int size);
66 static int mem_puts(
BIO *
h,
const char *str);
67 static int mem_gets(
BIO *
h,
char *str,
int size);
68 static long mem_ctrl(
BIO *
h,
int cmd,
long arg1,
void *arg2);
69 static int mem_new(
BIO *
h);
103 sz = (len<0) ? strlen(buf) : (size_t)len;
115 static int mem_new(
BIO *bi)
128 static int mem_free(
BIO *
a)
130 if (a == NULL)
return(0);
133 if ((a->
init) && (a->
ptr != NULL))
145 static int mem_read(
BIO *b,
char *out,
int outl)
152 ret=(outl >=0 && (size_t)outl > bm->
length)?(int)bm->
length:outl;
153 if ((out != NULL) && (ret > 0)) {
154 memcpy(out,bm->
data,ret);
160 }
else if (bm->
length == 0)
169 static int mem_write(
BIO *b,
const char *in,
int inl)
191 memcpy(&(bm->
data[blen]),in,inl);
197 static long mem_ctrl(
BIO *b,
int cmd,
long num,
void *
ptr)
207 if (bm->
data != NULL)
223 ret=(long)(bm->
length == 0);
233 *pptr=(
char *)&(bm->
data[0]);
274 static int mem_gets(
BIO *
bp,
char *buf,
int size)
283 if ((size-1) < j) j=size-1;
304 i=mem_read(bp,buf,i);
305 if (i > 0) buf[i]=
'\0';
310 static int mem_puts(
BIO *bp,
const char *str)
315 ret=mem_write(bp,str,n);