Commit a3b01d0f authored by Bernhard Link's avatar Bernhard Link

make main.c no longer need database_p.h

parent 3f328c75
......@@ -62,7 +62,9 @@ static /*@null@*/ char *rdb_version, *rdb_lastsupportedversion,
struct table *rdb_checksums, *rdb_contents;
struct table *rdb_references;
struct reprepro_database_capabilities rdb_capabilities;
static struct {
bool createnewtables;
} rdb_capabilities;
static void database_free(void) {
if (!rdb_initialized)
......@@ -2292,3 +2294,7 @@ retvalue database_translate_legacy_checksums(bool verbosedb) {
database_free();
return r;
}
bool database_allcreated(void) {
return rdb_capabilities.createnewtables;
}
......@@ -27,6 +27,7 @@ retvalue database_openreleasecache(const char *, /*@out@*/struct table **);
retvalue database_opentracking(const char *, bool /*readonly*/, /*@out@*/struct table **);
retvalue database_translate_filelists(void);
retvalue database_translate_legacy_checksums(bool /*verbosedb*/);
bool database_allcreated(void);
retvalue table_close(/*@only@*/struct table *);
......
......@@ -7,9 +7,6 @@
extern /*@null@*/ struct table *rdb_checksums, *rdb_contents;
extern /*@null@*/ struct table *rdb_references;
extern struct reprepro_database_capabilities {
bool createnewtables;
} rdb_capabilities;
retvalue database_listsubtables(const char *, /*@out@*/struct strlist *);
retvalue database_dropsubtable(const char *, const char *);
......
......@@ -39,7 +39,6 @@
#include "filecntl.h"
#include "files.h"
#include "filelist.h"
#include "database_p.h"
#include "target.h"
#include "reference.h"
#include "binaries.h"
......@@ -523,32 +522,7 @@ ACTION_R(n, n, n, y, removereferences) {
ACTION_R(n, n, n, n, dumpreferences) {
struct cursor *cursor;
retvalue result, r;
const char *found_to, *found_by;
r = table_newglobalcursor(rdb_references, &cursor);
if (!RET_IS_OK(r))
return r;
result = RET_OK;
while (cursor_nexttemp(rdb_references, cursor,
&found_to, &found_by)) {
if (fputs(found_by, stdout) == EOF ||
putchar(' ') == EOF ||
puts(found_to) == EOF) {
result = RET_ERROR;
break;
}
result = RET_OK;
if (interrupted()) {
result = RET_ERROR_INTERRUPTED;
break;
}
}
r = cursor_close(rdb_references, cursor);
RET_ENDUPDATE(result, r);
return result;
return references_dump();
}
static retvalue checkifreferenced(UNUSED(void *data), const char *filekey) {
......@@ -3276,10 +3250,9 @@ ACTION_D(n, n, n, clearvanished) {
if (verbose > 6)
printf(
"Marking '%s' as used.\n", t->identifier);
} else if (verbose > 3 && rdb_capabilities.createnewtables){
} else if (verbose > 3 && database_allcreated()){
fprintf(stderr,
"Strange, '%s' does not appear in packages.db yet.\n", t->identifier);
}
}
}
......
......@@ -183,3 +183,32 @@ retvalue references_remove(const char *neededby) {
return result;
}
/* dump all references to stdout */
retvalue references_dump(void) {
struct cursor *cursor;
retvalue result, r;
const char *found_to, *found_by;
r = table_newglobalcursor(rdb_references, &cursor);
if (!RET_IS_OK(r))
return r;
result = RET_OK;
while (cursor_nexttemp(rdb_references, cursor,
&found_to, &found_by)) {
if (fputs(found_by, stdout) == EOF ||
putchar(' ') == EOF ||
puts(found_to) == EOF) {
result = RET_ERROR;
break;
}
result = RET_OK;
if (interrupted()) {
result = RET_ERROR_INTERRUPTED;
break;
}
}
r = cursor_close(rdb_references, cursor);
RET_ENDUPDATE(result, r);
return result;
}
......@@ -44,4 +44,7 @@ retvalue references_isused(const char *);
/* check if a reference is found as expected */
retvalue references_check(const char * /*referee*/, const struct strlist */*what*/);
/* output all references to stdout */
retvalue references_dump(void);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment