diff options
author | Lennart Poettering <lennart@poettering.net> | 2003-08-26 21:43:31 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2003-08-26 21:43:31 +0000 |
commit | 3bc3ad24a2c089b4ee80fc1765fab3d2af378d00 (patch) | |
tree | 632a002b1c9a507ab49c11875eb373a6642902fb /src/dump.c | |
parent | d4a8a10792c7f9b777487b2d15ab56c737e7e35c (diff) |
Initial commit
git-svn-id: file:///home/lennart/svn/public/syrep/trunk@2 07ea20a6-d2c5-0310-9e02-9ef735347d72
Diffstat (limited to 'src/dump.c')
-rw-r--r-- | src/dump.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/dump.c b/src/dump.c new file mode 100644 index 0000000..c09da8d --- /dev/null +++ b/src/dump.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <assert.h> +#include <string.h> +#include <errno.h> +#include <sys/stat.h> + +#include "dump.h" +#include "package.h" + +static int foreach(struct package *p, char *name, char *path, void *u) { + struct stat st; + uint32_t size; + + if (stat(path, &st) < 0) { + if (errno == ENOENT) + size = 0; + else { + fprintf(stderr, "stat(%s) failed: %s\n", path, strerror(errno)); + return -1; + } + } else + size = (uint32_t) st.st_size; + + printf("%s (%u bytes)\n", name, size); + return 0; +} + +int dump(struct syrep_db_context *c) { + assert(c); + + return package_foreach(c->package, foreach, NULL); +} |