本文整理汇总了C++中APR_BRIGADE_FIRST函数的典型用法代码示例。如果您正苦于以下问题:C++ APR_BRIGADE_FIRST函数的具体用法?C++ APR_BRIGADE_FIRST怎么用?C++ APR_BRIGADE_FIRST使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了APR_BRIGADE_FIRST函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CaseFilterOutFilter
static apr_status_t CaseFilterOutFilter(ap_filter_t *f,
apr_bucket_brigade *pbbIn)
{
request_rec *r = f->r;
conn_rec *c = r->connection;
apr_bucket *pbktIn;
apr_bucket_brigade *pbbOut;
pbbOut=apr_brigade_create(r->pool, c->bucket_alloc);
for (pbktIn = APR_BRIGADE_FIRST(pbbIn);
pbktIn != APR_BRIGADE_SENTINEL(pbbIn);
pbktIn = APR_BUCKET_NEXT(pbktIn))
{
const char *data;
apr_size_t len;
char *buf;
apr_size_t n;
apr_bucket *pbktOut;
if(APR_BUCKET_IS_EOS(pbktIn))
{
apr_bucket *pbktEOS=apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(pbbOut,pbktEOS);
continue;
}
/* read */
apr_bucket_read(pbktIn,&data,&len,APR_BLOCK_READ);
/* write */
buf = apr_bucket_alloc(len, c->bucket_alloc);
for(n=0 ; n < len ; ++n)
buf[n] = apr_toupper(data[n]);
pbktOut = apr_bucket_heap_create(buf, len, apr_bucket_free,
c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(pbbOut,pbktOut);
}
/* Q: is there any advantage to passing a brigade for each bucket?
* A: obviously, it can cut down server resource consumption, if this
* experimental module was fed a file of 4MB, it would be using 8MB for
* the 'read' buckets and the 'write' buckets.
*
* Note it is more efficient to consume (destroy) each bucket as it's
* processed above than to do a single cleanup down here. In any case,
* don't let our caller pass the same buckets to us, twice;
*/
apr_brigade_cleanup(pbbIn);
return ap_pass_brigade(f->next,pbbOut);
}
示例2: h2_conn_io_bucket_read
static apr_status_t h2_conn_io_bucket_read(h2_conn_io *io,
apr_read_type_e block,
h2_conn_io_on_read_cb on_read_cb,
void *puser, int *pdone)
{
apr_status_t status = APR_SUCCESS;
apr_size_t readlen = 0;
*pdone = 0;
while (status == APR_SUCCESS && !*pdone
&& !APR_BRIGADE_EMPTY(io->input)) {
apr_bucket* bucket = APR_BRIGADE_FIRST(io->input);
if (APR_BUCKET_IS_METADATA(bucket)) {
/* we do nothing regarding any meta here */
}
else {
const char *bucket_data = NULL;
apr_size_t bucket_length = 0;
status = apr_bucket_read(bucket, &bucket_data,
&bucket_length, block);
if (status == APR_SUCCESS && bucket_length > 0) {
if (APLOGctrace2(io->connection)) {
char buffer[32];
h2_util_hex_dump(buffer, sizeof(buffer)/sizeof(buffer[0]),
bucket_data, bucket_length);
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, io->connection,
"h2_conn_io(%ld): read %d bytes: %s",
io->connection->id, (int)bucket_length, buffer);
}
if (bucket_length > 0) {
apr_size_t consumed = 0;
status = on_read_cb(bucket_data, bucket_length,
&consumed, pdone, puser);
if (status == APR_SUCCESS && bucket_length > consumed) {
/* We have data left in the bucket. Split it. */
status = apr_bucket_split(bucket, consumed);
}
readlen += consumed;
}
}
}
apr_bucket_delete(bucket);
}
if (readlen == 0 && status == APR_SUCCESS && block == APR_NONBLOCK_READ) {
return APR_EAGAIN;
}
return status;
}
示例3: jxr_append_brigade
apr_status_t jxr_append_brigade(request_rec *r, apr_bucket_brigade *dest, apr_bucket_brigade *bb, int *eos_seen)
{
apr_size_t max_msglen = MAX_PACKET_SIZE - sizeof(Jaxer_Header);
apr_status_t rv;
while (!APR_BRIGADE_EMPTY(bb))
{
apr_size_t readlen;
const char *buffer;
apr_bucket *e = APR_BRIGADE_FIRST(bb);
if (APR_BUCKET_IS_EOS(e) )
{
apr_bucket_delete(e);
if (eos_seen)
*eos_seen = 1;
continue;
}
if (APR_BUCKET_IS_METADATA(e)) {
apr_bucket_delete(e);
continue;
}
/* Read the bucket now */
if ((rv = apr_bucket_read(e, &buffer, &readlen, APR_BLOCK_READ)) != APR_SUCCESS)
{
ap_log_perror(APLOG_MARK, APLOG_INFO, rv, r->pool, "mod_jaxer: can't read data from handler");
return rv;
}
if (readlen > max_msglen)
{
apr_bucket_split(e, max_msglen);
}else
{
APR_BUCKET_REMOVE(e);
APR_BRIGADE_INSERT_TAIL(dest, e);
}
}
if ((rv=apr_brigade_destroy(bb)) != APR_SUCCESS)
{
ap_log_perror(APLOG_MARK, APLOG_INFO, rv, r->pool, "mod_jaxer: failed to destroy brigade.");
return rv;
}
return APR_SUCCESS;
}
示例4: jxr_send_brigade
apr_status_t jxr_send_brigade(jaxer_connection * ac, apr_bucket_brigade * bb)
{
apr_bucket *bucket;
apr_status_t rv;
compat_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, ac->request, "mod_jaxer: sending a brigade (sock=%d)", ac->sock);
for (bucket = APR_BRIGADE_FIRST(bb);
bucket != APR_BRIGADE_SENTINEL(bb);
bucket = APR_BUCKET_NEXT(bucket))
{
char *write_buf;
apr_size_t write_buf_len;
if (APR_BUCKET_IS_EOS(bucket))
break;
if (APR_BUCKET_IS_FLUSH(bucket))
continue;
if ((rv =
apr_bucket_read(bucket, (const char **)&write_buf, &write_buf_len,
APR_BLOCK_READ)) != APR_SUCCESS) {
compat_log_rerror(APLOG_MARK, APLOG_WARNING, rv, ac->request,
"mod_jaxer: can't read request from bucket");
return rv;
}
{
int type = jxr_msg_get_type(write_buf);
apr_size_t pos; // not used
apr_size_t len = jxr_msg_get_length(write_buf, &pos);
compat_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, ac->request, "mod_jaxer: sending a brigade (type=%s len=%d)", sBlockType[type], len);
}
/* Write the buffer to jaxer server */
if(0 > jxr_socket_sendfull(ac, write_buf, (int) write_buf_len))
{
compat_log_rerror(APLOG_MARK, APLOG_WARNING, APR_FROM_OS_ERROR(rv), ac->request,
"mod_jaxer: can't write to socket");
return apr_get_os_error();
}
}
compat_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, ac->request, "mod_jaxer: sent a brigade (sock=%d)", ac->sock);
return APR_SUCCESS;
}
示例5: cdn_html_filter
static int cdn_html_filter(ap_filter_t * f, apr_bucket_brigade * bb)
{
apr_bucket *b;
const char *buf = 0;
apr_size_t bytes = 0;
/* now do HTML filtering if necessary, and pass the brigade onward */
saxctxt *ctxt = check_html_filter_init(f);
if (!ctxt)
return ap_pass_brigade(f->next, bb);
for(b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) {
if(APR_BUCKET_IS_EOS(b) || APR_BUCKET_IS_FLUSH(b)) {
consume_buffer(ctxt, buf, 0, 1);
APR_BUCKET_REMOVE(b);
APR_BRIGADE_INSERT_TAIL(ctxt->bb, b);
ap_pass_brigade(ctxt->f->next, ctxt->bb);
return APR_SUCCESS;
}
if(apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ) == APR_SUCCESS && buf) {
if(ctxt->parser == NULL) {
/*
* for now, always output utf-8; we could incorporate
* mod_proxy_html's output transcoding with little problem if
* necessary
*/
ap_set_content_type(f->r, "text/html;charset=utf-8");
if(!initialize_parser(f, ctxt, &buf, bytes)) {
apr_status_t rv = ap_pass_brigade(ctxt->f->next, bb);
ap_remove_output_filter(f);
return rv;
} else
ap_fputs(f->next, ctxt->bb, ctxt->cfg->doctype);
}
consume_buffer(ctxt, buf, bytes, 0);
}
}
/*ap_fflush(ctxt->f->next, ctxt->bb) ; */ /* uncomment for debug */
apr_brigade_cleanup(bb);
return APR_SUCCESS;
}
示例6: getsfunc_BRIGADE
static int getsfunc_BRIGADE(char *buf, int len, void *arg)
{
apr_bucket_brigade *bb = (apr_bucket_brigade *)arg;
const char *dst_end = buf + len - 1; /* leave room for terminating null */
char *dst = buf;
apr_bucket *e = APR_BRIGADE_FIRST(bb);
apr_status_t rv;
int done = 0;
while ((dst < dst_end) && !done && e != APR_BRIGADE_SENTINEL(bb)
&& !APR_BUCKET_IS_EOS(e)) {
const char *bucket_data;
apr_size_t bucket_data_len;
const char *src;
const char *src_end;
apr_bucket * next;
rv = apr_bucket_read(e, &bucket_data, &bucket_data_len,
APR_BLOCK_READ);
if (rv != APR_SUCCESS || (bucket_data_len == 0)) {
*dst = '\0';
return APR_STATUS_IS_TIMEUP(rv) ? -1 : 0;
}
src = bucket_data;
src_end = bucket_data + bucket_data_len;
while ((src < src_end) && (dst < dst_end) && !done) {
if (*src == '\n') {
done = 1;
}
else if (*src != '\r') {
*dst++ = *src;
}
src++;
}
if (src < src_end) {
apr_bucket_split(e, src - bucket_data);
}
next = APR_BUCKET_NEXT(e);
apr_bucket_delete(e);
e = next;
}
*dst = 0;
return done;
}
示例7: AP_DECLARE
AP_DECLARE(apr_status_t) ap_save_brigade(ap_filter_t *f,
apr_bucket_brigade **saveto,
apr_bucket_brigade **b, apr_pool_t *p)
{
apr_bucket *e;
apr_status_t rv, srv = APR_SUCCESS;
/* If have never stored any data in the filter, then we had better
* create an empty bucket brigade so that we can concat.
*/
if (!(*saveto)) {
*saveto = apr_brigade_create(p, f->c->bucket_alloc);
}
for (e = APR_BRIGADE_FIRST(*b);
e != APR_BRIGADE_SENTINEL(*b);
e = APR_BUCKET_NEXT(e))
{
rv = apr_bucket_setaside(e, p);
/* If the bucket type does not implement setaside, then
* (hopefully) morph it into a bucket type which does, and set
* *that* aside... */
if (rv == APR_ENOTIMPL) {
const char *s;
apr_size_t n;
rv = apr_bucket_read(e, &s, &n, APR_BLOCK_READ);
if (rv == APR_SUCCESS) {
rv = apr_bucket_setaside(e, p);
}
}
if (rv != APR_SUCCESS) {
srv = rv;
/* Return an error but still save the brigade if
* ->setaside() is really not implemented. */
if (rv != APR_ENOTIMPL) {
return rv;
}
}
}
APR_BRIGADE_CONCAT(*saveto, *b);
return srv;
}
示例8: h2_util_bb_has_data_or_eos
int h2_util_bb_has_data_or_eos(apr_bucket_brigade *bb)
{
apr_bucket *b;
for (b = APR_BRIGADE_FIRST(bb);
b != APR_BRIGADE_SENTINEL(bb);
b = APR_BUCKET_NEXT(b))
{
if (APR_BUCKET_IS_METADATA(b)) {
if (APR_BUCKET_IS_EOS(b)) {
return 1;
}
}
else {
return 1;
}
}
return 0;
}
示例9: discard_script_output
static void discard_script_output(apr_bucket_brigade *bb)
{
apr_bucket *e;
const char *buf;
apr_size_t len;
apr_status_t rv;
e = APR_BRIGADE_FIRST(bb);
while (e != APR_BRIGADE_SENTINEL(bb)) {
if (APR_BUCKET_IS_EOS(e)) {
break;
}
rv = apr_bucket_read(e, &buf, &len, APR_BLOCK_READ);
if (rv != APR_SUCCESS) {
break;
}
e = APR_BUCKET_NEXT(e);
}
}
示例10: APU_DECLARE
APU_DECLARE(apr_status_t) apr_brigade_flatten(apr_bucket_brigade *bb,
char *c, apr_size_t *len)
{
apr_size_t actual = 0;
apr_bucket *b;
for (b = APR_BRIGADE_FIRST(bb);
b != APR_BRIGADE_SENTINEL(bb);
b = APR_BUCKET_NEXT(b))
{
const char *str;
apr_size_t str_len;
apr_status_t status;
status = apr_bucket_read(b, &str, &str_len, APR_BLOCK_READ);
if (status != APR_SUCCESS) {
return status;
}
/* If we would overflow. */
if (str_len + actual > *len) {
str_len = *len - actual;
}
/* XXX: It appears that overflow of the final bucket
* is DISCARDED without any warning to the caller.
*
* No, we only copy the data up to their requested size. -- jre
*/
memcpy(c, str, str_len);
c += str_len;
actual += str_len;
/* This could probably be actual == *len, but be safe from stray
* photons. */
if (actual >= *len) {
break;
}
}
*len = actual;
return APR_SUCCESS;
}
示例11: h2_util_has_eos
int h2_util_has_eos(apr_bucket_brigade *bb, apr_size_t len)
{
apr_bucket *b, *end;
apr_status_t status = last_not_included(bb, len, 0, 0, &end);
if (status != APR_SUCCESS) {
return status;
}
for (b = APR_BRIGADE_FIRST(bb);
b != APR_BRIGADE_SENTINEL(bb) && b != end;
b = APR_BUCKET_NEXT(b))
{
if (APR_BUCKET_IS_EOS(b)) {
return 1;
}
}
return 0;
}
示例12: ironbee_output_filter
/**
* @internal
*
* "Sniffs" the output (response) data from the connection stream.
*/
static int ironbee_output_filter (ap_filter_t *f, apr_bucket_brigade *bb)
{
apr_bucket *b;
#if 0
conn_rec *c = f->c;
ironbee_conn_context *ctx = f->ctx;
ib_conn_t *iconn = ctx->iconn;
ib_core_cfg_t *corecfg;
int buffering = 0;
/* Configure. */
ib_context_module_config(iconn->ctx, ib_core_module(), (void *)&corecfg);
if (corecfg != NULL) {
buffering = (int)corecfg->buffer_res;
}
#endif
for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) {
#if 0
/// @todo Should this be done? Maybe only for proxy?
if (APR_BUCKET_IS_EOS(b)) {
/// @todo Do we need to do this? Maybe only for proxy.
apr_bucket *flush = apr_bucket_flush_create(f->c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(b, flush);
}
if (buffering) {
/// @todo setaside into our own pool to destroy later???
apr_bucket_setaside(b, c->pool);
process_bucket(f, b);
APR_BUCKET_REMOVE(b);
}
else {
#endif
process_bucket(f, b);
#if 0
}
#endif
}
return ap_pass_brigade(f->next, bb);
}
示例13: dumpio_output_filter
static int dumpio_output_filter (ap_filter_t *f, apr_bucket_brigade *bb)
{
apr_bucket *b;
conn_rec *c = f->c;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c->base_server, "mod_dumpio: %s", f->frec->name) ;
for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) {
/*
* If we ever see an EOS, make sure to FLUSH.
*/
if (APR_BUCKET_IS_EOS(b)) {
apr_bucket *flush = apr_bucket_flush_create(f->c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(b, flush);
}
dumpit(f, b);
}
return ap_pass_brigade(f->next, bb) ;
}
示例14: urlReplaceFilterOutFilter
static apr_status_t urlReplaceFilterOutFilter(ap_filter_t *f,
apr_bucket_brigade *pbbIn)
{
request_rec *r = f->r;
conn_rec *c = r->connection;
apr_bucket *pbktIn;
apr_bucket_brigade *pbbOut;
pbbOut=apr_brigade_create(r->pool, c->bucket_alloc);
for (pbktIn = APR_BRIGADE_FIRST(pbbIn);
pbktIn != APR_BRIGADE_SENTINEL(pbbIn);
pbktIn = APR_BUCKET_NEXT(pbktIn))
{
const char *data;
apr_size_t len;
char *buf;
apr_size_t n;
apr_bucket *pbktOut;
if (APR_BUCKET_IS_EOS(pbktIn))
{
apr_bucket *pbktEOS=apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(pbbOut,pbktEOS);
continue;
}
/* read */
apr_bucket_read(pbktIn,&data,&len,APR_BLOCK_READ);
/* write */
buf = apr_bucket_alloc(len, c->bucket_alloc);
for (n=0 ; n < len ; ++n)
buf[n] = apr_toupper(data[n]);
pbktOut = apr_bucket_heap_create(buf, len, apr_bucket_free,
c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(pbbOut,pbktOut);
}
apr_brigade_cleanup(pbbIn);
return ap_pass_brigade(f->next,pbbOut);
}
示例15: APU_DECLARE
APU_DECLARE(apr_status_t) apr_brigade_split_line(apr_bucket_brigade *bbOut,
apr_bucket_brigade *bbIn,
apr_read_type_e block,
apr_off_t maxbytes)
{
apr_off_t readbytes = 0;
while (!APR_BRIGADE_EMPTY(bbIn)) {
const char *pos;
const char *str;
apr_size_t len;
apr_status_t rv;
apr_bucket *e;
e = APR_BRIGADE_FIRST(bbIn);
rv = apr_bucket_read(e, &str, &len, block);
if (rv != APR_SUCCESS) {
return rv;
}
pos = memchr(str, APR_ASCII_LF, len);
/* We found a match. */
if (pos != NULL) {
apr_bucket_split(e, pos - str + 1);
APR_BUCKET_REMOVE(e);
APR_BRIGADE_INSERT_TAIL(bbOut, e);
return APR_SUCCESS;
}
APR_BUCKET_REMOVE(e);
APR_BRIGADE_INSERT_TAIL(bbOut, e);
readbytes += len;
/* We didn't find an APR_ASCII_LF within the maximum line length. */
if (readbytes >= maxbytes) {
break;
}
}
return APR_SUCCESS;
}