Exemplo n.º 1
0
static ret_t
do_download__read_body (cherokee_downloader_t *downloader, void *param)
{
    ret_t             ret;
    ssize_t           len;
    cherokee_buffer_t tmp = CHEROKEE_BUF_INIT;

    UNUSED(param);

    /* Write down
     */
    len = write (output_fd, downloader->body.buf, downloader->body.len);
    if (len > 0) {
        ret = cherokee_buffer_move_to_begin (&downloader->body, len);
        if (ret != ret_ok) return ret;
    }

    /* Print info
     */
    cherokee_buffer_add_fsize (&tmp, downloader->content_length);
    cherokee_buffer_add_str   (&tmp, " of ");
    cherokee_buffer_add_fsize (&tmp, downloader->info.body_recv);

    if (! quiet) {
        fprintf (stderr, "\rDownloading: %s", tmp.buf);
        fflush(stderr);
    }

    cherokee_buffer_mrproper (&tmp);
    return ret_ok;
}
Exemplo n.º 2
0
static ret_t
get_stats_cb (cherokee_cache_t  *cache,
	      cherokee_buffer_t *info)
{
	size_t total = 0;

	cherokee_iocache_get_mmaped_size (IOCACHE(cache), &total);

	cherokee_buffer_add_str (info, "IOcache mappped: ");
	cherokee_buffer_add_fsize (info, total);
	cherokee_buffer_add_str (info, "\n");

	return ret_ok;
}