libsqsh v1.5.2
Loading...
Searching...
No Matches
list_xattrs.c
Go to the documentation of this file.
1
9#include <assert.h>
10#include <sqsh.h>
11#include <stdio.h>
12#include <stdlib.h>
13
14int
15main(int argc, char *argv[]) {
16 if (argc != 3) {
17 printf("Usage: %s <sqsh-file> <path>\n", argv[0]);
18 return 1;
19 }
20 struct SqshArchive *archive = sqsh_archive_open(argv[1], NULL, NULL);
21 assert(archive != NULL);
22
23 char **keys = sqsh_easy_xattr_keys(archive, argv[2], NULL);
24 assert(keys != NULL);
25 for (int i = 0; keys[i] != NULL; i++) {
26 char *value = sqsh_easy_xattr_get(archive, argv[2], keys[i], NULL);
27 printf("%s=%s\n", keys[i], value);
28 free(value);
29 }
30 free(keys);
31
32 sqsh_archive_close(archive);
33 return 0;
34}
int main(int argc, char *argv[])
Definition list_xattrs.c:15
char * sqsh_easy_xattr_get(struct SqshArchive *archive, const char *path, const char *key, int *err)
retrieves the value of a xattr key of a file or directory.
char ** sqsh_easy_xattr_keys(struct SqshArchive *archive, const char *path, int *err)
retrieves all xattr keys of a file or directory.
SQSH_NO_UNUSED struct SqshArchive * sqsh_archive_open(const void *source, const struct SqshConfig *config, int *err)
initializes a archive context in heap.
int sqsh_archive_close(struct SqshArchive *archive)
Frees the resources used by a Sqsh instance.