65 static int linebuffer_write(
BIO *
h,
const char *buf,
int num);
66 static int linebuffer_read(
BIO *
h,
char *buf,
int size);
67 static int linebuffer_puts(
BIO *
h,
const char *str);
68 static int linebuffer_gets(
BIO *
h,
char *str,
int size);
69 static long linebuffer_ctrl(
BIO *
h,
int cmd,
long arg1,
void *arg2);
70 static int linebuffer_new(
BIO *
h);
71 static int linebuffer_free(
BIO *
data);
75 #define DEFAULT_LINEBUFFER_SIZE 1024*10
90 linebuffer_callback_ctrl,
95 return(&methods_linebuffer);
105 static int linebuffer_new(
BIO *bi)
110 if (ctx == NULL)
return(0);
122 static int linebuffer_free(
BIO *
a)
126 if (a == NULL)
return(0);
136 static int linebuffer_read(
BIO *b,
char *out,
int outl)
140 if (out == NULL)
return(0);
148 static int linebuffer_write(
BIO *b,
const char *in,
int inl)
153 if ((in == NULL) || (inl <= 0))
return(0);
155 if ((ctx == NULL) || (b->
next_bio == NULL))
return(0);
163 for(p = in; p < in + inl && *p !=
'\n'; p++)
216 if (i < 0)
return((num > 0)?num:i);
217 if (i == 0)
return(num);
222 if (i < ctx->obuf_len)
230 if ((foundnl || p - in > ctx->
obuf_size) && p - in > 0)
242 if (i < 0)
return((num > 0)?num:i);
243 if (i == 0)
return(num);
253 while(foundnl && inl > 0);
266 static long linebuffer_ctrl(
BIO *b,
int cmd,
long num,
void *
ptr)
339 fprintf(stderr,
"FLUSH %3d -> %3d\n",ctx->
obuf_len,r);
342 if (r <= 0)
return((
long)r);
343 if (r < ctx->obuf_len)
387 static int linebuffer_gets(
BIO *b,
char *buf,
int size)
393 static int linebuffer_puts(
BIO *b,
const char *str)
395 return(linebuffer_write(b,str,strlen(str)));