This library loads CURL from an Aroma Module instead of statically linking it to the binary. This results in a much smaller binary size (saves about 750KiB).
- Requires the [CURLWrapperModule](https://github.com/wiiu-env/CURLWrapperModule) to be running via [WUMSLoader](https://github.com/wiiu-env/WUMSLoader).
- Requires [wut](https://github.com/devkitPro/wut) for building.
- Use with curl 7.84.0 headers, other versions might not be compatible.
- See important changes in the Usage section.
Install via `make install`.
## Usage
Make sure to define this in your Makefile:
```
WUMS_ROOT := $(DEVKITPRO)/wums
```
Use the normal curl headers, but link against `-lcurlwrapper` instead. For example replace `-lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lz` with `-lcurlwrapper`.
**If the CURLWrapperModule is not loaded `curl_global_init` will return a negative value.**
## Changes compared to normal CURL
libcurlwrapper tries to be a drop-in replacement for libcurl, but some things need to be considered.
### All function are only available between calling `curl_global_init` and `curl_global_cleanup`.
Even functions like `curl_version` only work after calling `curl_global_init`.
### Calling `curl_easy_init` will automatically add CA certificates.
It `curl_easy_init` returns success, `curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob);` with current CA certificates will be called.
These CA certificates are coming from the modules and can be updated in the future.
### CURLOPT_SOCKOPTFUNCTION
- The `CURLOPT_SOCKOPTFUNCTION` callback requires a workaround to work properly.
- This is caused by `setsockopt` not being compatible with the sockets from the CURLWrapperModule.
Currently, there are two options to get the correct `setsockopt` function:
#### Option 1: CURLOPT_SOCKOPTDATA
- To get a pointer to the correct `setsockopt` function, you have to set the `CURLOPT_SOCKOPTDATA` to 0x13371337.
- The `0x13371337` will be replaced with a pointer to the correct `setsockopt` function.
Example:
```C
static int initSocket(void *ptr, curl_socket_t socket, curlsocktype type) {
int r;
// If ptr is not our magic value, it got replaced with a pointer to a valid setsockopt function.
if ((uint32_t) ptr != 0x13371337) {
r = reinterpret_cast<decltype(&setsockopt)>(ptr)(socket, SOL_SOCKET, SO_WINSCALE, &o, sizeof(o));
} else {
r = setsockopt(socket, SOL_SOCKET, SO_WINSCALE, &o, sizeof(o));
}
return r == 0 ? CURL_SOCKOPT_OK : CURL_SOCKOPT_ERROR;
}
[...]
// Set socktopt data to a magic value to get a pointer to the correct setsockopt function.
Replace [tag] with a tag you want to use, a list of tags can be found [here](https://github.com/wiiu-env/libcurlwrapper/pkgs/container/libcurlwrapper/versions).