Saturday, August 13, 2011

liblrzip is go

Another day, another project done. Liblrzip is the latest, a full API for the excellent LRZIP for which I wrote a build system way back in March. Straight to the code, here's a VERY simple example of a decompression app using the library:


static const char *suffix_me(const char *file)
const char *p;
static char buf[4096];

p = strrchr(file, '.');
if (p && (strlen(p + 1) < 4))
strncat(buf, file, p - file);
strcat(buf, file);
return &buf[0];

int main(int argc, char *argv[])
Lrzip *lr;
if ((argc != 2) && (argc != 3)) {
fprintf(stderr, "Usage: %s file [outfile]\n", argv[0]);
lr = lrzip_new(LRZIP_MODE_DECOMPRESS);
assert(lrzip_filename_add(lr, argv[1]));
if (argc == 2)
lrzip_outfilename_set(lr, suffix_me(argv[1]));
lrzip_outfilename_set(lr, argv[2]);
return 0;

Yes, I am too lazy to figure out the CSS to preserve whitespaces for indentation.

No comments:

Post a Comment