summaryrefslogtreecommitdiffstats
path: root/src/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c67
1 files changed, 21 insertions, 46 deletions
diff --git a/src/list.c b/src/list.c
index 333a780..e5fe62f 100644
--- a/src/list.c
+++ b/src/list.c
@@ -30,13 +30,21 @@
#include "dbutil.h"
#include "syrep.h"
-static int handle_file(struct syrep_db_context *c, const struct syrep_name *name, const struct syrep_md *md, const struct syrep_meta *meta) {
+static int handle_file(struct syrep_db_context *c, const struct syrep_nrecno *nrecno, const struct syrep_md *md, const struct syrep_meta *meta) {
struct syrep_meta local_meta;
- assert(c && name && md);
+ struct syrep_name name;
+ int f;
+
+ assert(c && nrecno && md);
+
+ if ((f = get_name_by_nrecno(c, nrecno, &name)) < 0)
+ return -1;
+ assert(f);
+
if (!meta) {
int f;
- if ((f = get_meta_by_name_md(c, name, md, &local_meta)) < 0)
+ if ((f = get_meta_by_nrecno_md(c, nrecno, md, &local_meta)) < 0)
return -1;
if (f)
@@ -52,9 +60,9 @@ static int handle_file(struct syrep_db_context *c, const struct syrep_name *name
fhex(md->digest, SYREP_DIGESTLENGTH, d);
d[SYREP_DIGESTLENGTH*2] = 0;
- printf("%s %s%s", d, name->path, meta->last_seen == c->version ? "\t\t" : "\t(deleted)");
+ printf("%s %s%s", d, name.path, meta->last_seen == c->version ? "\t\t" : "\t(deleted)");
} else
- printf("\t%s%s", name->path, meta->last_seen == c->version ? "\t\t" : "\t(deleted)");
+ printf("\t%s%s", name.path, meta->last_seen == c->version ? "\t\t" : "\t(deleted)");
if (args.show_times_flag)
printf( "\t(first-seen: %u; last-seen: %u)\n", meta->first_seen, meta->last_seen);
@@ -65,7 +73,7 @@ static int handle_file(struct syrep_db_context *c, const struct syrep_name *name
fhex(md->digest, SYREP_DIGESTLENGTH, d);
d[SYREP_DIGESTLENGTH*2] = 0;
- printf("\t%s", name->path);
+ printf("\t%s", name.path);
}
return 0;
@@ -76,45 +84,12 @@ int list(struct syrep_db_context *c) {
DBC *cursor = NULL;
DBT key, data;
-
-#if 1
-
- {
- if ((ret = c->db_name_lastmd->cursor(c->db_name_lastmd, NULL, &cursor, 0)) != 0) {
- c->db_name_lastmd->err(c->db_name_lastmd, ret, "db_name_lastmd");
- goto finish;
- }
-
- memset(&key, 0, sizeof(key));
- memset(&data, 0, sizeof(data));
-
- while ((ret = cursor->c_get(cursor, &key, &data, DB_NEXT)) == 0) {
- struct syrep_name *name = (struct syrep_name*) key.data;
- struct syrep_md *md = (struct syrep_md*) data.data;
-
- if (handle_file(c, name, md, NULL) < 0)
- fprintf(stderr, "handle_file() failed\n");
-
- }
-
- if (ret != DB_NOTFOUND) {
- c->db_name_lastmd->err(c->db_name_lastmd, ret, "name_lastmd::c_get");
- goto finish;
- }
-
- r = 0;
- }
-
- goto finish;
-
-#endif
-
if (args.show_by_md_flag) {
struct syrep_md previous_md;
memset(&previous_md, 0, sizeof(previous_md));
- if ((ret = c->db_md_name->cursor(c->db_md_name, NULL, &cursor, 0)) != 0) {
- c->db_md_name->err(c->db_md_name, ret, "md_name");
+ if ((ret = c->db_md_nrecno->cursor(c->db_md_nrecno, NULL, &cursor, 0)) != 0) {
+ c->db_md_nrecno->err(c->db_md_nrecno, ret, "md_nrecno");
goto finish;
}
@@ -123,7 +98,7 @@ int list(struct syrep_db_context *c) {
while ((ret = cursor->c_get(cursor, &key, &data, DB_NEXT)) == 0) {
struct syrep_md *md = (struct syrep_md*) key.data;
- struct syrep_name *name = (struct syrep_name*) data.data;
+ struct syrep_nrecno *recno = (struct syrep_nrecno*) data.data;
struct syrep_meta meta;
if (memcmp(&previous_md, md, sizeof(previous_md))) {
@@ -134,15 +109,15 @@ int list(struct syrep_db_context *c) {
memcpy(&previous_md, md, sizeof(previous_md));
}
- if ((ret = get_meta_by_name_md(c, name, md, &meta)) < 0)
+ if ((ret = get_meta_by_nrecno_md(c, recno, md, &meta)) < 0)
goto finish;
- if (handle_file(c, name, md, &meta) < 0)
+ if (handle_file(c, recno, md, &meta) < 0)
fprintf(stderr, "handle_file() failed\n");
}
if (ret != DB_NOTFOUND) {
- c->db_md_name->err(c->db_md_name, ret, "md_name::c_get");
+ c->db_md_nrecno->err(c->db_md_nrecno, ret, "md_nrecno::c_get");
goto finish;
}
@@ -160,7 +135,7 @@ int list(struct syrep_db_context *c) {
while ((ret = cursor->c_get(cursor, &key, &data, DB_NEXT)) == 0) {
struct syrep_id *id = (struct syrep_id*) key.data;
- if (handle_file(c, &id->name, &id->md, (struct syrep_meta*) data.data) < 0)
+ if (handle_file(c, &id->nrecno, &id->md, (struct syrep_meta*) data.data) < 0)
fprintf(stderr, "handle_file() failed\n");
}