nekos-best.c 1.0.0
A simple, lightweight c wrapper for nekos.best API
|
This file contains structs and functions for interacting with the nekos.best API. More...
Go to the source code of this file.
Data Structures | |
struct | nekos_endpoint |
Struct for an endpoint/category. More... | |
struct | nekos_endpoint_list |
Struct for a list of endpoints/categories. More... | |
struct | nekos_source_gif |
Struct for a gif source. More... | |
struct | nekos_source_png |
Struct for a png source. More... | |
struct | nekos_result |
Struct for a result image. More... | |
struct | nekos_result_list |
Struct for a list of result images. More... | |
struct | nekos_http_response |
Struct for an http response. More... | |
Enumerations | |
enum | nekos_status { NEKOS_OK , NEKOS_MEM_ERR , NEKOS_LIBCURL_ERR , NEKOS_CJSON_ERR , NEKOS_INVALID_PARAM_ERR } |
Status codes for the nekos.best c wrapper. More... | |
enum | nekos_format { NEKOS_PNG , NEKOS_GIF } |
Enum for the format of the image. More... | |
Functions | |
nekos_status | nekos_endpoints (nekos_endpoint_list *endpoints) |
Get a list of endpoints/categories. | |
nekos_endpoint * | nekos_find_endpoint (const nekos_endpoint_list *endpoints, const char *name) |
Find a specific endpoint in a list of endpoints/categories. | |
nekos_status | nekos_category (nekos_result_list *results, const nekos_endpoint *endpoint, int amount) |
Get a list of images from a category. | |
nekos_status | nekos_search (nekos_result_list *results, const char *raw_query, int amount, const nekos_format format, const nekos_endpoint *endpoint) |
Search for images. | |
nekos_status | nekos_download (nekos_http_response *http_response, const char *url) |
Download an image. | |
void | nekos_free_endpoint (const nekos_endpoint *endpoint) |
Free an endpoint. | |
void | nekos_free_endpoints (const nekos_endpoint_list *endpoints) |
Free a list of endpoints. | |
void | nekos_free_result (const nekos_result *result) |
Free a result. | |
void | nekos_free_results (const nekos_result_list *results) |
Free a list of results. | |
void | nekos_free_http_response (const nekos_http_response *http_response) |
Free an http response. | |
This file contains structs and functions for interacting with the nekos.best API.
enum nekos_status |
Status codes for the nekos.best c wrapper.
enum nekos_format |
Enum for the format of the image.
Enumerator | |
---|---|
NEKOS_PNG | Indicates that the response image is a png and nekos_source_png should be used. |
NEKOS_GIF | Indicates that the response image is a gif and nekos_source_gif should be used. |
nekos_status nekos_endpoints | ( | nekos_endpoint_list * | endpoints | ) |
Get a list of endpoints/categories.
This function fetches the endpoints
endpoint of the api and parses the response into a list of endpoints.
It will allocate memory for the list of endpoints and the endpoints themselves.
[out] | endpoints | Pointer to a nekos_endpoint_list to store the endpoints in. |
nekos_endpoint * nekos_find_endpoint | ( | const nekos_endpoint_list * | endpoints, |
const char * | name | ||
) |
Find a specific endpoint in a list of endpoints/categories.
This function searches for a specific endpoint in a list of endpoints by name.
[in] | endpoints | Pointer to a nekos_endpoint_list to search in. |
[in] | name | Name of the endpoint to search for. |
nekos_status nekos_category | ( | nekos_result_list * | results, |
const nekos_endpoint * | endpoint, | ||
int | amount | ||
) |
Get a list of images from a category.
This function fetches the specified category endpoint of the api and parses the response into a list of images.
It will allocate memory for the list of results, the results themselves, and the source information.
[out] | results | Pointer to a nekos_result_list to store the results in. |
[in] | endpoint | Pointer to a nekos_endpoint to specify the category. |
[in] | amount | Amount of images to fetch. Must be between 1 and NEKOS_MAX_AMOUNT. |
nekos_status nekos_search | ( | nekos_result_list * | results, |
const char * | raw_query, | ||
int | amount, | ||
const nekos_format | format, | ||
const nekos_endpoint * | endpoint | ||
) |
Search for images.
This function fetches the search
endpoint of the api and parses the response into a list of images.
The search can optionally specify a endpoint/category.
It will allocate memory for the list of results, the results themselves, and the source information.
[out] | results | Pointer to a nekos_result_list to store the results in. |
[in] | raw_query | Query to search for. Must be between NEKOS_MIN_QUERY_LEN and NEKOS_MAX_QUERY_LEN. |
[in] | amount | Amount of images to fetch. Must be between 1 and NEKOS_MAX_AMOUNT. |
[in] | format | Format of the images to search for. |
[in] | endpoint | Pointer to a nekos_endpoint to specify a category. Can be NULL. |
nekos_status nekos_download | ( | nekos_http_response * | http_response, |
const char * | url | ||
) |
Download an image.
This function fetches the specified image url and stores the response in a nekos_http_response .
It will allocate memory for the response text.
[out] | http_response | Pointer to a nekos_http_response to store the response in. |
[in] | url | URL of the image to download. |
void nekos_free_endpoint | ( | const nekos_endpoint * | endpoint | ) |
Free an endpoint.
This function frees the memory allocated for the endpoint.
[in] | endpoint | Pointer to a nekos_endpoint to free. |
void nekos_free_endpoints | ( | const nekos_endpoint_list * | endpoints | ) |
Free a list of endpoints.
This function frees the memory allocated for the list of endpoints and the endpoints themselves.
[in] | endpoints | Pointer to a nekos_endpoint_list to free. |
void nekos_free_result | ( | const nekos_result * | result | ) |
Free a result.
This function frees the memory allocated for the result and the source information.
[in] | result | Pointer to a nekos_result to free. |
void nekos_free_results | ( | const nekos_result_list * | results | ) |
Free a list of results.
This function frees the memory allocated for the list of results, the results themselves, and the source information.
[in] | results | Pointer to a nekos_result_list to free. |
void nekos_free_http_response | ( | const nekos_http_response * | http_response | ) |
Free an http response.
This function frees the memory allocated for the response text.
[in] | http_response | Pointer to a nekos_http_response to free. |