|
otakugifs.c 1.0.0
A simple, lightweight c wrapper the otakugifs.xyz API
|
This file contains structs and functions for interacting with the otakugifs.xyz API. More...
Go to the source code of this file.
Data Structures | |
| struct | otaku_reaction_list |
| Struct for a list of reactions. More... | |
| struct | otaku_result |
| Struct for a result. More... | |
| struct | otaku_http_response |
| Struct for an http response. More... | |
Macros | |
| #define | OTAKU_BASE_URL "https://api.otakugifs.xyz/gif" |
| Base URL for the otakugifs.xyz API. | |
Enumerations | |
| enum | otaku_status { OTAKU_OK , OTAKU_MEM_ERR , OTAKU_LIBCURL_ERR , OTAKU_CJSON_ERR } |
| Status codes for the otakugifs.xyz c wrapper. More... | |
| enum | otaku_format { OTAKU_GIF , OTAKU_WEBP , OTAKU_AVIF } |
| Enum for the format of the image. More... | |
Functions | |
| otaku_status | otaku_reactions (otaku_reaction_list *reactions) |
| Get a list of reactions. | |
| bool | otaku_is_reaction (const otaku_reaction_list *reactions, const char *name) |
| Check if a reaction exists. | |
| otaku_status | otaku_reaction (otaku_result *result, const char *reaction, otaku_format format) |
| Fetch a reaction. | |
| otaku_status | otaku_download (otaku_http_response *http_response, const char *url) |
| Download an image. | |
| void | otaku_free_reactions (const otaku_reaction_list *reactions) |
| Free a list of reactions. | |
| void | otaku_free_result (const otaku_result *result) |
| Free a result. | |
| void | otaku_free_http_response (const otaku_http_response *http_response) |
| Free an http response. | |
This file contains structs and functions for interacting with the otakugifs.xyz API.
| enum otaku_status |
Status codes for the otakugifs.xyz c wrapper.
| enum otaku_format |
| otaku_status otaku_reactions | ( | otaku_reaction_list * | reactions | ) |
Get a list of reactions.
This function fetches the allreactions endpoint of the api and parses the response into a list of reactions.
It will allocate memory for the list of reactions and the reactions themselves.
| [out] | reactions | Pointer to a otaku_reaction_list to store the reactions in. |
| bool otaku_is_reaction | ( | const otaku_reaction_list * | reactions, |
| const char * | name | ||
| ) |
Check if a reaction exists.
This function searches for a specific reaction in a list of reactions by name.
| [in] | reactions | Pointer to a otaku_reaction_list to search in. |
| [in] | name | Name of the reaction to search for. |
| otaku_status otaku_reaction | ( | otaku_result * | result, |
| const char * | reaction, | ||
| otaku_format | format | ||
| ) |
Fetch a reaction.
This function fetches the specified reaction endpoint of the api and parses the response into a result reaction.
It will allocate memory for the result.
| [out] | result | Pointer to a otaku_result to store the result in. |
| [in] | reaction | Reaction to fetch. Must be a valid reaction. |
| [in] | format | Format of the result. |
| otaku_status otaku_download | ( | otaku_http_response * | http_response, |
| const char * | url | ||
| ) |
Download an image.
This function fetches the specified image url and stores the response in a otaku_http_response .
It will allocate memory for the response text.
| [out] | http_response | Pointer to a otaku_http_response to store the response in. |
| [in] | url | URL of the image to download. |
| void otaku_free_reactions | ( | const otaku_reaction_list * | reactions | ) |
Free a list of reactions.
This function frees the memory allocated for the list of reactions and the reactions themselves.
| [in] | reactions | Pointer to a otaku_reaction_list to free. |
| void otaku_free_result | ( | const otaku_result * | result | ) |
Free a result.
This function frees the memory allocated for the result.
| [in] | result | Pointer to a otaku_result to free. |
| void otaku_free_http_response | ( | const otaku_http_response * | http_response | ) |
Free an http response.
This function frees the memory allocated for the response text.
| [in] | http_response | Pointer to a otaku_http_response to free. |