MCPcopy Create free account
hub / github.com/apache/httpd / brigade_peek

Function brigade_peek

modules/echo/mod_echo.c:54–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54static apr_status_t brigade_peek(apr_bucket_brigade *bbIn,
55 char *buff, apr_size_t bufflen)
56{
57 apr_bucket *b;
58 apr_size_t readbytes = 0;
59
60 if (bufflen--)
61 /* compensate for NULL */
62 *buff = '\0';
63 else
64 return APR_EGENERAL;
65
66 if (APR_BRIGADE_EMPTY(bbIn))
67 return APR_EGENERAL;
68
69 b = APR_BRIGADE_FIRST(bbIn);
70
71 while ((b != APR_BRIGADE_SENTINEL(bbIn)) && (readbytes < bufflen)) {
72 const char *pos;
73 const char *str;
74 apr_size_t len;
75 apr_status_t rv;
76
77 if ((rv = apr_bucket_read(b, &str, &len, APR_NONBLOCK_READ))
78 != APR_SUCCESS)
79 return rv;
80
81 if ((pos = memchr(str, APR_ASCII_LF, len)) != NULL)
82 len = pos - str;
83 if (len > bufflen - readbytes)
84 len = bufflen - readbytes;
85 memcpy (buff + readbytes, str, len);
86 readbytes += len;
87 buff[readbytes] = '\0';
88
89 b = APR_BUCKET_NEXT(b);
90 }
91 return APR_SUCCESS;
92}
93
94
95static int update_echo_child_status(ap_sb_handle_t *sbh,

Callers 1

update_echo_child_statusFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected