MCPcopy Create free account
hub / github.com/ading2210/linuxpdf / block_device_init_http

Function block_device_init_http

tinyemu/block_net.c:404–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402}
403
404BlockDevice *block_device_init_http(const char *url,
405 int max_cache_size_kb,
406 void (*start_cb)(void *opaque),
407 void *start_opaque)
408{
409 BlockDevice *bs;
410 BlockDeviceHTTP *bf;
411 char *p;
412
413 bs = mallocz(sizeof(*bs));
414 bf = mallocz(sizeof(*bf));
415 strcpy(bf->url, url);
416 /* get the path with the trailing '/' */
417 p = strrchr(bf->url, '/');
418 if (!p)
419 p = bf->url;
420 else
421 p++;
422 *p = '\0';
423
424 init_list_head(&bf->cached_blocks);
425 bf->max_cache_size_kb = max_cache_size_kb;
426 bf->start_cb = start_cb;
427 bf->start_opaque = start_opaque;
428 bf->bs = bs;
429
430 bs->opaque = bf;
431 bs->get_sector_count = bf_get_sector_count;
432 bs->read_async = bf_read_async;
433 bs->write_async = bf_write_async;
434
435 fs_wget(url, NULL, NULL, bs, bf_init_onload, TRUE);
436 return bs;
437}
438
439static void bf_init_onload(void *opaque, int err, void *data, size_t size)
440{

Callers 2

mainFunction · 0.85
init_vm_driveFunction · 0.85

Calls 3

malloczFunction · 0.85
init_list_headFunction · 0.85
fs_wgetFunction · 0.85

Tested by

no test coverage detected