A simple, lightweight c wrapper the otakugifs.xyz API compliant with C99.
Join the official Discord server here.
Requirements
- libcurl (tested with 8.7.1-6)
- cjson (tested with 1.7.17-1)
Installation
Copy the single header file to source include directory and include the header. Specify OTAKUGIFS_IMPL
before including the header in the source file where you want to use the library.
#define OTAKUGIFS_IMPL
This file contains structs and functions for interacting with the otakugifs.xyz API.
Documentation
Doxygen documentation is available here. (Jump to otakugifs.h)
Example
#define OTAKUGIFS_IMPL
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *file = fopen("kiss.gif", "wb");
fwrite(http_response.
text, 1, http_response.
len, file);
fclose(file);
return EXIT_SUCCESS;
}
@ OTAKU_GIF
Indicates that the response image is a gif.
Definition otakugifs.h:30
void otaku_free_http_response(const otaku_http_response *http_response)
Free an http response.
otaku_status otaku_reaction(otaku_result *result, const char *reaction, otaku_format format)
Fetch a reaction.
void otaku_free_result(const otaku_result *result)
Free a result.
otaku_status otaku_download(otaku_http_response *http_response, const char *url)
Download an image.
Struct for an http response.
Definition otakugifs.h:50
char * text
[out] Non-nullterminated text of the response.
Definition otakugifs.h:51
size_t len
[out] Length of the response text.
Definition otakugifs.h:52
Struct for a result.
Definition otakugifs.h:42
char * url
[out] URL to the result.
Definition otakugifs.h:44
This example fetches a gif from the 'kiss' endpoint saves it to a file. Please note that this example does not handle errors.
For more examples, see tests/
.