Created
March 28, 2019 17:13
-
-
Save rohanpadhye/57eb57cd4592f5368d7f24584d4f88f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdlib.h" | |
#include "stdio.h" | |
#include "archive.h" | |
#include "archive_entry.h" | |
int main(int argc, char** argv) { | |
struct archive *a; | |
struct archive_entry *entry; | |
int r; | |
char buf[10240]; | |
a = archive_read_new(); | |
archive_read_support_filter_all(a); | |
archive_read_support_format_all(a); | |
r = archive_read_open_filename(a, "/dev/stdin", 10240); | |
if (r != ARCHIVE_OK) { | |
printf("Error opening archive\n"); | |
exit(1); | |
} | |
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) { | |
printf("entry name: %s\n", archive_entry_pathname(entry)); | |
while ((r = archive_read_data(a, buf, sizeof(buf))) > 0) { | |
printf("Read %d bytes\n", r); | |
} | |
if (r != ARCHIVE_OK) { | |
printf("Error reading data: %s\n", archive_error_string(a)); | |
break; | |
} | |
} | |
r = archive_read_free(a); | |
if (r != ARCHIVE_OK) { | |
printf("Error freeing memory\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment