BSB Developer Docs
Loading...
Searching...
No Matches
fetch_loader.h File Reference

Simple file downloader library. More...

#include "fetch_common.h"

Go to the source code of this file.

Typedefs

typedef struct FetchLoader FetchLoader
 Opaque FetchLoader structure declaration.
 
typedef void(* FetchLoaderProgressCallback) (const FetchProgress *progress, void *context)
 Progress callback function type.
 
typedef void(* FetchLoaderStateCallback) (const char *message, void *context)
 State callback function type.
 
typedef void(* FetchLoaderDoneCallback) (FetchStatus status, void *context)
 Done callback function type.
 

Functions

FetchLoader * fetch_loader_alloc (void)
 Create a FetchLoader instance.
 
void fetch_loader_free (FetchLoader *instance)
 Delete a FetchLoader instance.
 
void fetch_loader_start (FetchLoader *instance, const char *remote_url, const char *file_path)
 Start downloading a file.
 
void fetch_loader_stop (FetchLoader *instance)
 Request the download process to be stopped.
 
void fetch_loader_set_callback_context (FetchLoader *instance, void *context)
 Set the context for callback functions.
 
void fetch_loader_set_progress_callback (FetchLoader *instance, FetchLoaderProgressCallback callback)
 Set the callback function for progress notifications.
 
void fetch_loader_set_state_callback (FetchLoader *instance, FetchLoaderStateCallback callback)
 Set the callback function for state notifications.
 
void fetch_loader_set_done_callback (FetchLoader *instance, FetchLoaderDoneCallback callback)
 Set the callback function for completion notifications.
 

Detailed Description

Simple file downloader library.

Typedef Documentation

◆ FetchLoaderDoneCallback

typedef void(* FetchLoaderDoneCallback) (FetchStatus status, void *context)

Done callback function type.

Parameters
[in]statusvalue from FetchStatus enum representing the completion status
[in,out]contextpointer to a user-specific object

◆ FetchLoaderProgressCallback

typedef void(* FetchLoaderProgressCallback) (const FetchProgress *progress, void *context)

Progress callback function type.

Parameters
[in]progresspointer to the structure containing download progress information
[in,out]contextpointer to a user-specific object

◆ FetchLoaderStateCallback

typedef void(* FetchLoaderStateCallback) (const char *message, void *context)

State callback function type.

Parameters
[in]messagepointer to a zero-terminated string with a message about current state
[in,out]contextpointer to a user-specific object

Function Documentation

◆ fetch_loader_alloc()

FetchLoader * fetch_loader_alloc ( void )

Create a FetchLoader instance.

Returns
pointer to the created instance

◆ fetch_loader_free()

void fetch_loader_free ( FetchLoader * instance)

Delete a FetchLoader instance.

Parameters
[in,out]instancepointer to the instance to be deleted

◆ fetch_loader_set_callback_context()

void fetch_loader_set_callback_context ( FetchLoader * instance,
void * context )

Set the context for callback functions.

Parameters
[in,out]instancepointer to the instance to be modified
[in]contextpointer to the user-specific object (will be passed to the callbacks)

◆ fetch_loader_set_done_callback()

void fetch_loader_set_done_callback ( FetchLoader * instance,
FetchLoaderDoneCallback callback )

Set the callback function for completion notifications.

Parameters
[in,out]instancepointer to the instance to be modified
[in]callbackpointer to the function to be called upon completion

◆ fetch_loader_set_progress_callback()

void fetch_loader_set_progress_callback ( FetchLoader * instance,
FetchLoaderProgressCallback callback )

Set the callback function for progress notifications.

Parameters
[in,out]instancepointer to the instance to be modified
[in]callbackpointer to the function to be called on progress changes

◆ fetch_loader_set_state_callback()

void fetch_loader_set_state_callback ( FetchLoader * instance,
FetchLoaderStateCallback callback )

Set the callback function for state notifications.

Parameters
[in,out]instancepointer to the instance to be modified
[in]callbackpointer to the function to be called on new state messages

◆ fetch_loader_start()

void fetch_loader_start ( FetchLoader * instance,
const char * remote_url,
const char * file_path )

Start downloading a file.

This function spawns a separate thread and does not block.

Parameters
[in,out]instancepointer to the instance to be started
[in]remote_urlzero-terminated string with a full URL of the file to download
[in]file_pathzero-terminated string with a full path to the output file

◆ fetch_loader_stop()

void fetch_loader_stop ( FetchLoader * instance)

Request the download process to be stopped.

This function does not block. Callers must wait for the done callback to be triggered before attempting to restart or delete the instance.

Parameters
[in,out]instancepointer to the instance to be stopped