Links: libarchive and their github.
It may seem a little archaic at first, but it flows pretty well once you understand it. I've added an example program that's 95% a copy of their simple read example.
#include <stdio.h>
#include <archive.h>
int main() {
struct archive_entry *ae;
const char * filename = "test.rar";
int r;
size_t size;
struct archive *a = archive_read_new();
archive_read_support_compression_all(a);
archive_read_support_format_rar(a);
r = archive_read_open_filename(a, filename, 16384);
if (r != ARCHIVE_OK) {
/* ERROR */
}
r = archive_read_next_header(a, &ae);
if (r != ARCHIVE_OK) {
/* ERROR */
}
char buff[1000];
int buffsize = sizeof(buff);
for (;;) {
size = archive_read_data(a, buff, buffsize);
if (size < 0) {
/* ERROR */
}
if (size == 0)
break;
write(1, buff, size);
}
archive_read_free(a);
}