![]() |
BSB Developer Docs
|
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. | |
Simple file downloader library.
| typedef void(* FetchLoaderDoneCallback) (FetchStatus status, void *context) |
Done callback function type.
| [in] | status | value from FetchStatus enum representing the completion status |
| [in,out] | context | pointer to a user-specific object |
| typedef void(* FetchLoaderProgressCallback) (const FetchProgress *progress, void *context) |
Progress callback function type.
| [in] | progress | pointer to the structure containing download progress information |
| [in,out] | context | pointer to a user-specific object |
| typedef void(* FetchLoaderStateCallback) (const char *message, void *context) |
State callback function type.
| [in] | message | pointer to a zero-terminated string with a message about current state |
| [in,out] | context | pointer to a user-specific object |
| FetchLoader * fetch_loader_alloc | ( | void | ) |
Create a FetchLoader instance.
| void fetch_loader_free | ( | FetchLoader * | instance | ) |
Delete a FetchLoader instance.
| [in,out] | instance | pointer to the instance to be deleted |
| void fetch_loader_set_callback_context | ( | FetchLoader * | instance, |
| void * | context ) |
Set the context for callback functions.
| [in,out] | instance | pointer to the instance to be modified |
| [in] | context | pointer to the user-specific object (will be passed to the callbacks) |
| void fetch_loader_set_done_callback | ( | FetchLoader * | instance, |
| FetchLoaderDoneCallback | callback ) |
Set the callback function for completion notifications.
| [in,out] | instance | pointer to the instance to be modified |
| [in] | callback | pointer to the function to be called upon completion |
| void fetch_loader_set_progress_callback | ( | FetchLoader * | instance, |
| FetchLoaderProgressCallback | callback ) |
Set the callback function for progress notifications.
| [in,out] | instance | pointer to the instance to be modified |
| [in] | callback | pointer to the function to be called on progress changes |
| void fetch_loader_set_state_callback | ( | FetchLoader * | instance, |
| FetchLoaderStateCallback | callback ) |
Set the callback function for state notifications.
| [in,out] | instance | pointer to the instance to be modified |
| [in] | callback | pointer to the function to be called on new state messages |
| 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.
| [in,out] | instance | pointer to the instance to be started |
| [in] | remote_url | zero-terminated string with a full URL of the file to download |
| [in] | file_path | zero-terminated string with a full path to the output file |
| 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.
| [in,out] | instance | pointer to the instance to be stopped |