serf_bucket_t *serf_bucket_aggregate_create( serf_bucket_alloc_t *allocator) { aggregate_context_t *ctx; ctx = create_aggregate(allocator); return serf_bucket_create(&serf_bucket_type_aggregate, allocator, ctx); }
SERF_DECLARE(serf_bucket_t *) serf_bucket_barrier_create( serf_bucket_t *stream, serf_bucket_alloc_t *allocator) { barrier_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->stream = stream; return serf_bucket_create(&serf_bucket_type_barrier, allocator, ctx); }
serf_bucket_t *serf_bucket_limit_create( serf_bucket_t *stream, apr_uint64_t len, serf_bucket_alloc_t *allocator) { limit_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->stream = stream; ctx->remaining = len; return serf_bucket_create(&serf_bucket_type_limit, allocator, ctx); }
serf_bucket_t *serf_bucket_headers_create( serf_bucket_alloc_t *allocator) { headers_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->list = NULL; ctx->state = READ_START; return serf_bucket_create(&serf_bucket_type_headers, allocator, ctx); }
serf_bucket_t *serf_bucket_chunk_create( serf_bucket_t *stream, serf_bucket_alloc_t *allocator) { chunk_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->state = STATE_FETCH; ctx->chunk = serf_bucket_aggregate_create(allocator); ctx->stream = stream; return serf_bucket_create(&serf_bucket_type_chunk, allocator, ctx); }
SERF_DECLARE(serf_bucket_t *) serf_bucket_dechunk_create( serf_bucket_t *stream, serf_bucket_alloc_t *allocator) { dechunk_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->stream = stream; ctx->state = STATE_SIZE; serf_linebuf_init(&ctx->linebuf); return serf_bucket_create(&serf_bucket_type_dechunk, allocator, ctx); }
SERF_DECLARE(serf_bucket_t *) serf_bucket_mmap_create( apr_mmap_t *file_mmap, serf_bucket_alloc_t *allocator) { mmap_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->mmap = file_mmap; ctx->current = NULL; ctx->offset = 0; ctx->remaining = ctx->mmap->size; return serf_bucket_create(&serf_bucket_type_mmap, allocator, ctx); }
serf_bucket_t *serf_bucket_mock_create(mockbkt_action *actions, int len, serf_bucket_alloc_t *allocator) { mockbkt_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->actions = actions; ctx->len = len; ctx->current_data = 0l; ctx->remaining_data = -1; ctx->current_action = 0; ctx->remaining_times = -1; return serf_bucket_create(&serf_bucket_type_mock, allocator, ctx); }
serf_bucket_t *serf_bucket_simple_own_create( const char *data, apr_size_t len, serf_bucket_alloc_t *allocator) { simple_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->original = ctx->current = data; ctx->remaining = len; ctx->freefunc = free_copied_data; ctx->baton = allocator; return serf_bucket_create(&serf_bucket_type_simple, allocator, ctx); }
SERF_DECLARE(serf_bucket_t *) serf_bucket_socket_create( apr_socket_t *skt, serf_bucket_alloc_t *allocator) { socket_context_t *ctx; /* Oh, well. */ ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->skt = skt; serf_databuf_init(&ctx->databuf); ctx->databuf.read = socket_reader; ctx->databuf.read_baton = ctx; ctx->progress_func = ctx->progress_baton = NULL; return serf_bucket_create(&serf_bucket_type_socket, allocator, ctx); }
static serf_bucket_t * serf_bucket_ssl_create( serf_ssl_context_t *ssl_ctx, serf_bucket_alloc_t *allocator, const serf_bucket_type_t *type) { ssl_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); if (!ssl_ctx) { ctx->ssl_ctx = ssl_init_context(); } else { ctx->ssl_ctx = ssl_ctx; } ctx->ssl_ctx->refcount++; return serf_bucket_create(type, allocator, ctx); }
SERF_DECLARE(serf_bucket_t *) serf_bucket_simple_create( const char *data, apr_size_t len, serf_simple_freefunc_t freefunc, void *freefunc_baton, serf_bucket_alloc_t *allocator) { simple_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->current = data; ctx->remaining = len; ctx->original = NULL; ctx->original_len = -1; ctx->freefunc = freefunc; ctx->baton = freefunc_baton; return serf_bucket_create(&serf_bucket_type_simple, allocator, ctx); }
serf_bucket_t *serf_bucket_response_create( serf_bucket_t *stream, serf_bucket_alloc_t *allocator) { response_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->stream = stream; ctx->body = NULL; ctx->headers = serf_bucket_headers_create(allocator); ctx->state = STATE_STATUS_LINE; ctx->chunked = 0; ctx->head_req = 0; serf_linebuf_init(&ctx->linebuf); return serf_bucket_create(&serf_bucket_type_response, allocator, ctx); }
serf_bucket_t *serf_bucket_iovec_create( struct iovec vecs[], int len, serf_bucket_alloc_t *allocator) { iovec_context_t *ctx; int i; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->vecs = serf_bucket_mem_alloc(allocator, len * sizeof(struct iovec)); ctx->vecs_len = len; ctx->current_vec = 0; ctx->offset = 0; /* copy all buffers to our iovec. */ for (i = 0; i < len; i++) { ctx->vecs[i].iov_base = vecs[i].iov_base; ctx->vecs[i].iov_len = vecs[i].iov_len; } return serf_bucket_create(&serf_bucket_type_iovec, allocator, ctx); }
serf_bucket_t *serf_bucket_deflate_create( serf_bucket_t *stream, serf_bucket_alloc_t *allocator, int format) { deflate_context_t *ctx; ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); ctx->stream = stream; ctx->stream_status = APR_SUCCESS; ctx->inflate_stream = serf_bucket_aggregate_create(allocator); ctx->format = format; ctx->crc = 0; ctx->config = NULL; /* zstream must be NULL'd out. */ memset(&ctx->zstream, 0, sizeof(ctx->zstream)); switch (ctx->format) { case SERF_DEFLATE_GZIP: ctx->state = STATE_READING_HEADER; break; case SERF_DEFLATE_DEFLATE: /* deflate doesn't have a header. */ ctx->state = STATE_INIT; break; default: /* Not reachable */ return NULL; } /* Initial size of gzip header. */ ctx->stream_left = ctx->stream_size = DEFLATE_MAGIC_SIZE; ctx->windowSize = DEFLATE_WINDOW_SIZE; ctx->memLevel = DEFLATE_MEMLEVEL; ctx->bufferSize = DEFLATE_BUFFER_SIZE; return serf_bucket_create(&serf_bucket_type_deflate, allocator, ctx); }