This library could be used to bring funny xkcd web-comics to your applications.
Like this:
Do you remember? Live example. The work was inspired by existing Python package.
There are no specific external dependencies except stuff in standards and popular OpenSSL (>= 1.1.1) library. Implemented both static and shared thread-safe variants.
Supported interfaces:
- Plain C
- Modern C++
- Python-3 binding
Pre-built packages:
- Ubuntu 18.04 LTS, amd64
- Ubuntu 20.04 LTS, amd64
Ready packages are available from Canonical PPA:
$ sudo add-apt-repository --yes --update ppa:vyivanov/xkcdxx
$ sudo apt install --yes xkcdxx python3-xkcdxx
- Plain C – complete interface
#include <xkcd.h>
#include <stdio.h>
xkcd_comic idx = xkcd_comic_latest();
if (idx) {
xkcd_info info = xkcd_comic_info(idx);
printf("%s", info.url);
xkcd_comic_destroy(idx);
idx = XKCD_COMIC_NULL;
} else {
printf("%s", xkcd_comic_error());
}
- Modern C++ – complete interface
#include <xkcdxx.h>
#include <iostream>
try {
xkcdxx::Comic comic{xkcdxx::Comic::Number::Latest};
std::cout << comic.url();
} catch (xkcdxx::Comic::RequestFailed& ex) {
std::cout << ex.what();
}
- Python-3 binding – complete interface
import xkcdxx
try:
comic = xkcdxx.Comic(xkcdxx.Comic.LATEST)
print(comic.url())
except xkcdxx.Comic.RequestFailed as ex:
print(ex)