Commit 76478837 authored by Bernhard Link's avatar Bernhard Link

[refactor] replace target_cursor with package_cursor

parent 114db736
......@@ -29,6 +29,7 @@
#include "distribution.h"
#include "tracking.h"
#include "files.h"
#include "package.h"
#include "archallflood.h"
struct aa_source_name {
......@@ -315,8 +316,7 @@ static retvalue save_package_version(struct floodlist *list, const char *package
static retvalue floodlist_initialize(struct floodlist **fl, struct target *t) {
struct floodlist *list;
retvalue r, r2;
const char *packagename, *controlchunk;
struct target_cursor iterator;
struct package_cursor iterator;
list = zNEW(struct floodlist);
if (FAILEDTOALLOC(list))
......@@ -326,18 +326,19 @@ static retvalue floodlist_initialize(struct floodlist **fl, struct target *t) {
/* Begin with the packages currently in the archive */
r = target_openiterator(t, READONLY, &iterator);
r = package_openiterator(t, READONLY, &iterator);
if (RET_WAS_ERROR(r)) {
floodlist_free(list);
return r;
}
while (target_nextpackage(&iterator, &packagename, &controlchunk)) {
r2 = save_package_version(list, packagename, controlchunk);
while (package_next(&iterator)) {
r2 = save_package_version(list,
iterator.current.name, iterator.current.control);
RET_UPDATE(r, r2);
if (RET_WAS_ERROR(r2))
break;
}
r2 = target_closeiterator(&iterator);
r2 = package_closeiterator(&iterator);
RET_UPDATE(r, r2);
if (RET_WAS_ERROR(r)) {
......@@ -558,19 +559,18 @@ static retvalue floodlist_trypackage(struct floodlist *list, const char *package
static retvalue floodlist_pull(struct floodlist *list, struct target *source) {
retvalue result, r;
const char *package, *control;
struct target_cursor iterator;
struct package_cursor iterator;
list->last = NULL;
r = target_openiterator(source, READONLY, &iterator);
r = package_openiterator(source, READONLY, &iterator);
if (RET_WAS_ERROR(r))
return r;
result = RET_NOTHING;
while (target_nextpackage(&iterator, &package, &control)) {
while (package_next(&iterator)) {
char *version;
architecture_t package_architecture;
r = list->target->getarchitecture(control,
r = list->target->getarchitecture(iterator.current.control,
&package_architecture);
if (r == RET_NOTHING)
continue;
......@@ -581,14 +581,15 @@ static retvalue floodlist_pull(struct floodlist *list, struct target *source) {
if (package_architecture != architecture_all)
continue;
r = list->target->getversion(control, &version);
r = list->target->getversion(iterator.current.control, &version);
if (r == RET_NOTHING)
continue;
if (!RET_IS_OK(r)) {
RET_UPDATE(result, r);
break;
}
r = floodlist_trypackage(list, package, version, control);
r = floodlist_trypackage(list, iterator.current.name,
version, iterator.current.control);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
......@@ -597,7 +598,7 @@ static retvalue floodlist_pull(struct floodlist *list, struct target *source) {
break;
}
}
r = target_closeiterator(&iterator);
r = package_closeiterator(&iterator);
RET_ENDUPDATE(result, r);
return result;
}
......
/* This file is part of "reprepro"
* Copyright (C) 2006,2007 Bernhard R. Link
* Copyright (C) 2006,2007,2016 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -33,6 +33,7 @@
#include "files.h"
#include "ignore.h"
#include "configparser.h"
#include "package.h"
/* options are zerroed when called, when error is returned contentsopions_done
* is called by the caller */
......@@ -187,7 +188,7 @@ static retvalue gentargetcontents(struct target *target, struct release *release
char *contentsfilename;
struct filetorelease *file;
struct filelist_list *contents;
struct target_cursor iterator;
struct package_cursor iterator;
if (onlyneeded && target->saved_wasmodified)
onlyneeded = false;
......@@ -230,18 +231,19 @@ static retvalue gentargetcontents(struct target *target, struct release *release
release_abortfile(file);
return r;
}
result = target_openiterator(target, READONLY, &iterator);
result = package_openiterator(target, READONLY, &iterator);
if (RET_IS_OK(result)) {
const char *package, *control;
while (target_nextpackage(&iterator, &package, &control)) {
while (package_next(&iterator)) {
r = addpackagetocontents(target->distribution,
target, package, control, contents);
target,
iterator.current.name,
iterator.current.control,
contents);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
}
r = target_closeiterator(&iterator);
r = package_closeiterator(&iterator);
RET_ENDUPDATE(result, r);
}
if (!RET_WAS_ERROR(result))
......
......@@ -479,23 +479,23 @@ retvalue copy_by_name(struct distribution *into, struct distribution *from, int
static retvalue by_source(struct package_list *list, struct target *desttarget, struct target *fromtarget, void *data) {
struct namelist *d = data;
struct target_cursor iterator;
const char *packagename, *chunk;
struct package_cursor iterator;
retvalue result, r;
assert (d->argc > 0);
r = target_openiterator(fromtarget, READONLY, &iterator);
r = package_openiterator(fromtarget, READONLY, &iterator);
assert (r != RET_NOTHING);
if (!RET_IS_OK(r))
return r;
result = RET_NOTHING;
while (target_nextpackage(&iterator, &packagename, &chunk)) {
while (package_next(&iterator)) {
int i;
char *source, *sourceversion;
architecture_t package_architecture;
r = fromtarget->getsourceandversion(chunk, packagename,
r = fromtarget->getsourceandversion(iterator.current.control,
iterator.current.name,
&source, &sourceversion);
if (r == RET_NOTHING)
continue;
......@@ -519,7 +519,7 @@ static retvalue by_source(struct package_list *list, struct target *desttarget,
assert (r != RET_NOTHING);
if (RET_WAS_ERROR(r)) {
free(source); free(sourceversion);
(void)target_closeiterator(&iterator);
(void)package_closeiterator(&iterator);
return r;
}
if (c == 0)
......@@ -533,20 +533,23 @@ static retvalue by_source(struct package_list *list, struct target *desttarget,
}
}
free(source); free(sourceversion);
r = fromtarget->getarchitecture(chunk, &package_architecture);
r = fromtarget->getarchitecture(iterator.current.control,
&package_architecture);
if (RET_WAS_ERROR(r)) {
result = r;
break;
}
r = list_prepareadd(list, desttarget,
packagename, NULL, package_architecture, chunk);
iterator.current.name, NULL,
package_architecture,
iterator.current.control);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
d->found[0] = true;
d->found[i] = true;
}
r = target_closeiterator(&iterator);
r = package_closeiterator(&iterator);
RET_ENDUPDATE(result, r);
return result;
}
......@@ -632,67 +635,70 @@ retvalue copy_by_source(struct distribution *into, struct distribution *from, in
static retvalue by_formula(struct package_list *list, struct target *desttarget, struct target *fromtarget, void *data) {
term *condition = data;
struct target_cursor iterator;
const char *packagename, *chunk;
struct package_cursor iterator;
architecture_t package_architecture;
retvalue result, r;
r = target_openiterator(fromtarget, READONLY, &iterator);
r = package_openiterator(fromtarget, READONLY, &iterator);
assert (r != RET_NOTHING);
if (!RET_IS_OK(r))
return r;
result = RET_NOTHING;
while (target_nextpackage(&iterator, &packagename, &chunk)) {
r = term_decidechunktarget(condition, chunk, desttarget);
while (package_next(&iterator)) {
r = term_decidechunktarget(condition, iterator.current.control,
desttarget);
if (r == RET_NOTHING)
continue;
if (RET_WAS_ERROR(r)) {
result = r;
break;
}
r = fromtarget->getarchitecture(chunk, &package_architecture);
r = fromtarget->getarchitecture(iterator.current.control,
&package_architecture);
if (RET_WAS_ERROR(r)) {
result = r;
break;
}
r = list_prepareadd(list, desttarget,
packagename, NULL, package_architecture, chunk);
iterator.current.name, NULL,
package_architecture, iterator.current.control);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
}
r = target_closeiterator(&iterator);
r = package_closeiterator(&iterator);
RET_ENDUPDATE(result, r);
return result;
}
static retvalue by_glob(struct package_list *list, struct target *desttarget, struct target *fromtarget, void *data) {
const char *glob = data;
struct target_cursor iterator;
const char *packagename, *chunk;
struct package_cursor iterator;
architecture_t package_architecture;
retvalue result, r;
r = target_openiterator(fromtarget, READONLY, &iterator);
r = package_openiterator(fromtarget, READONLY, &iterator);
assert (r != RET_NOTHING);
if (!RET_IS_OK(r))
return r;
result = RET_NOTHING;
while (target_nextpackage(&iterator, &packagename, &chunk)) {
if (!globmatch(packagename, glob))
while (package_next(&iterator)) {
if (!globmatch(iterator.current.name, glob))
continue;
r = fromtarget->getarchitecture(chunk, &package_architecture);
r = fromtarget->getarchitecture(iterator.current.control,
&package_architecture);
if (RET_WAS_ERROR(r)) {
result = r;
break;
}
r = list_prepareadd(list, desttarget,
packagename, NULL, package_architecture, chunk);
iterator.current.name, NULL,
package_architecture, iterator.current.control);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
}
r = target_closeiterator(&iterator);
r = package_closeiterator(&iterator);
RET_ENDUPDATE(result, r);
return result;
}
......
/* This file is part of "reprepro"
* Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010 Bernhard R. Link
* Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010,2016 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -39,6 +39,7 @@
#include "uploaderslist.h"
#include "configparser.h"
#include "byhandhook.h"
#include "package.h"
#include "distribution.h"
static retvalue distribution_free(struct distribution *distribution) {
......@@ -535,8 +536,7 @@ retvalue distribution_readall(struct distribution **distributions) {
retvalue distribution_foreach_package(struct distribution *distribution, const struct atomlist *components, const struct atomlist *architectures, const struct atomlist *packagetypes, each_package_action action, each_target_action target_action, void *data) {
retvalue result, r;
struct target *t;
struct target_cursor iterator;
const char *package, *control;
struct package_cursor iterator;
result = RET_NOTHING;
for (t = distribution->targets ; t != NULL ; t = t->next) {
......@@ -549,17 +549,20 @@ retvalue distribution_foreach_package(struct distribution *distribution, const s
if (r == RET_NOTHING)
continue;
}
r = target_openiterator(t, READONLY, &iterator);
r = package_openiterator(t, READONLY, &iterator);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
return result;
while (target_nextpackage(&iterator, &package, &control)) {
r = action(distribution, t, package, control, data);
while (package_next(&iterator)) {
r = action(distribution, t,
iterator.current.name,
iterator.current.control,
data);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
}
r = target_closeiterator(&iterator);
r = package_closeiterator(&iterator);
RET_ENDUPDATE(result, r);
if (RET_WAS_ERROR(result))
return result;
......@@ -570,8 +573,7 @@ retvalue distribution_foreach_package(struct distribution *distribution, const s
retvalue distribution_foreach_package_c(struct distribution *distribution, const struct atomlist *components, architecture_t architecture, packagetype_t packagetype, each_package_action action, void *data) {
retvalue result, r;
struct target *t;
const char *package, *control;
struct target_cursor iterator;
struct package_cursor iterator;
result = RET_NOTHING;
for (t = distribution->targets ; t != NULL ; t = t->next) {
......@@ -582,17 +584,20 @@ retvalue distribution_foreach_package_c(struct distribution *distribution, const
continue;
if (limitation_missed(packagetype, t->packagetype))
continue;
r = target_openiterator(t, READONLY, &iterator);
r = package_openiterator(t, READONLY, &iterator);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
return result;
while (target_nextpackage(&iterator, &package, &control)) {
r = action(distribution, t, package, control, data);
while (package_next(&iterator)) {
r = action(distribution, t,
iterator.current.name,
iterator.current.control,
data);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
}
r = target_closeiterator(&iterator);
r = package_closeiterator(&iterator);
RET_ENDUPDATE(result, r);
if (RET_WAS_ERROR(result))
return result;
......@@ -1105,8 +1110,7 @@ retvalue distribution_prepareforwriting(struct distribution *distribution) {
retvalue distribution_remove_packages(struct distribution *distribution, const struct atomlist *components, const struct atomlist *architectures, const struct atomlist *packagetypes, each_package_action decider, struct trackingdata *trackingdata, void *data) {
retvalue result, r;
struct target *t;
struct target_cursor iterator;
const char *package, *control;
struct package_cursor iterator;
if (distribution->readonly) {
fprintf(stderr,
......@@ -1119,24 +1123,26 @@ retvalue distribution_remove_packages(struct distribution *distribution, const s
for (t = distribution->targets ; t != NULL ; t = t->next) {
if (!target_matches(t, components, architectures, packagetypes))
continue;
r = target_openiterator(t, READWRITE, &iterator);
r = package_openiterator(t, READWRITE, &iterator);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
return result;
while (target_nextpackage(&iterator, &package, &control)) {
while (package_next(&iterator)) {
r = decider(distribution, t,
package, control, data);
iterator.current.name,
iterator.current.control,
data);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
if (RET_IS_OK(r)) {
r = target_removepackage_by_cursor(&iterator,
r = package_remove_by_cursor(&iterator,
distribution->logger, trackingdata);
RET_UPDATE(result, r);
RET_UPDATE(distribution->status, r);
}
}
r = target_closeiterator(&iterator);
r = package_closeiterator(&iterator);
RET_ENDUPDATE(result, r);
if (RET_WAS_ERROR(result))
return result;
......
/* This file is part of "reprepro"
* Copyright (C) 2005,2007,2008,2009 Bernhard R. Link
* Copyright (C) 2005,2007,2008,2009,2016 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -37,6 +37,7 @@
#include "configparser.h"
#include "filecntl.h"
#include "hooks.h"
#include "package.h"
static const char *exportdescription(const struct exportmode *mode, char *buffer, size_t buffersize) {
char *result = buffer;
......@@ -462,9 +463,7 @@ retvalue export_target(const char *relativedir, struct target *target, const st
const char *status;
char *relfilename;
char buffer[100];
const char *chunk;
size_t chunk_len;
struct target_cursor iterator;
struct package_cursor iterator;
relfilename = calc_dirconcat(relativedir, exportmode->filename);
if (FAILEDTOALLOC(relfilename))
......@@ -490,22 +489,22 @@ retvalue export_target(const char *relativedir, struct target *target, const st
exportdescription(exportmode, buffer, 100));
status = "new";
}
r = target_openiterator(target, READONLY, &iterator);
r = package_openiterator(target, READONLY, &iterator);
if (RET_WAS_ERROR(r)) {
release_abortfile(file);
free(relfilename);
return r;
}
while (target_nextpackage_len(&iterator, NULL,
&chunk, &chunk_len)) {
if (chunk_len == 0)
while (package_next(&iterator)) {
if (iterator.current.controllen == 0)
continue;
(void)release_writedata(file, chunk, chunk_len);
(void)release_writedata(file, iterator.current.control,
iterator.current.controllen);
(void)release_writestring(file, "\n");
if (chunk[chunk_len-1] != '\n')
if (iterator.current.control[iterator.current.controllen-1] != '\n')
(void)release_writestring(file, "\n");
}
r = target_closeiterator(&iterator);
r = package_closeiterator(&iterator);
if (RET_WAS_ERROR(r)) {
release_abortfile(file);
free(relfilename);
......
......@@ -2512,9 +2512,8 @@ ACTION_F(y, n, y, y, reoverride) {
/*****************retrieving Description data from .deb files***************/
static retvalue repair_descriptions(struct target *target) {
struct target_cursor iterator;
struct package_cursor iterator;
retvalue result, r;
const char *package, *controlchunk;
assert(target->packages == NULL);
assert(target->packagetype == pt_deb || target->packagetype == pt_udeb);
......@@ -2525,11 +2524,11 @@ static retvalue repair_descriptions(struct target *target) {
target->identifier);
}
r = target_openiterator(target, READWRITE, &iterator);
r = package_openiterator(target, READWRITE, &iterator);
if (!RET_IS_OK(r))
return r;
result = RET_NOTHING;
while (target_nextpackage(&iterator, &package, &controlchunk)) {
while (package_next(&iterator)) {
char *newcontrolchunk = NULL;
if (interrupted()) {
......@@ -2537,17 +2536,19 @@ static retvalue repair_descriptions(struct target *target) {
break;
}
/* replace it by itself to normalize the Description field */
r = description_addpackage(target, package, controlchunk,
controlchunk, NULL, &newcontrolchunk);
r = description_addpackage(target, iterator.current.name,
iterator.current.control,
iterator.current.control, NULL,
&newcontrolchunk);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
if (RET_IS_OK(r)) {
if (verbose >= 0) {
printf(
"Fixing description for '%s'...\n", package);
"Fixing description for '%s'...\n", iterator.current.name);
}
r = cursor_replace(target->packages, iterator.cursor,
r = package_newcontrol_by_cursor(&iterator,
newcontrolchunk, strlen(newcontrolchunk));
free(newcontrolchunk);
if (RET_WAS_ERROR(r)) {
......@@ -2557,7 +2558,7 @@ static retvalue repair_descriptions(struct target *target) {
target->wasmodified = true;
}
}
r = target_closeiterator(&iterator);
r = package_closeiterator(&iterator);
RET_ENDUPDATE(result, r);
return result;
}
......@@ -5186,3 +5187,7 @@ int main(int argc, char *argv[]) {
myexit(EXIT_FAILURE);
}
retvalue package_newcontrol_by_cursor(struct package_cursor *cursor, const char *newcontrol, size_t newcontrollen) {
return cursor_replace(cursor->target->packages, cursor->cursor,
newcontrol, newcontrollen);
}
......@@ -12,6 +12,8 @@ struct package {
char *pkgchunk, *pkgname;
};
struct target;
struct logger;
struct trackingdata;
retvalue package_get(struct target *, const char * /*name*/, /*@null@*/ const char */*version*/, /*@out@*/ struct package *);
......@@ -22,4 +24,18 @@ static inline void package_done(struct package *pkg) {
memset(pkg, 0, sizeof(*pkg));
}
struct package_cursor {
/*@temp@*/struct target *target;
struct cursor *cursor;
struct package current;
};
retvalue package_openiterator(struct target *, bool /*readonly*/, /*@out@*/struct package_cursor *);
bool package_next(struct package_cursor *);
retvalue package_closeiterator(struct package_cursor *);
retvalue package_remove_by_cursor(struct package_cursor *, /*@null@*/struct logger *, /*@null@*/struct trackingdata *);
retvalue package_newcontrol_by_cursor(struct package_cursor *, const char *, size_t);
#endif
/* This file is part of "reprepro"
* Copyright (C) 2010,2011 Bernhard R. Link
* Copyright (C) 2010,2011,2016 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -24,6 +24,7 @@
#include "error.h"
#include "distribution.h"
#include "trackingt.h"
#include "package.h"
#include "sourcecheck.h"
/* This is / will be the implementation of the
......@@ -69,31 +70,30 @@ static void free_source_info(struct info_source *s) {
static retvalue collect_source_versions(struct distribution *d, struct info_source **out) {
struct info_source *root = NULL, *last = NULL;
struct target *t;
struct target_cursor target_cursor = TARGET_CURSOR_ZERO;
const char *name, *chunk;
struct package_cursor cursor;
retvalue result = RET_NOTHING, r;
for (t = d->targets ; t != NULL ; t = t->next) {
if (t->architecture != architecture_source)
continue;
r = target_openiterator(t, true, &target_cursor);
r = package_openiterator(t, true, &cursor);
if (RET_WAS_ERROR(r)) {
RET_UPDATE(result, r);
break;
}
while (target_nextpackage(&target_cursor, &name, &chunk)) {
while (package_next(&cursor)) {
char *version;
struct info_source **into = NULL;
struct info_source_version *v;
r = t->getversion(chunk, &version);
r = t->getversion(cursor.current.control, &version);
if (!RET_IS_OK(r)) {
RET_UPDATE(result, r);
continue;
}
if (last != NULL) {
int c;
c = strcmp(name, last->name);
c = strcmp(cursor.current.name, last->name);
if (c < 0) {
/* start at the beginning */
last = NULL;
......@@ -102,7 +102,7 @@ static retvalue collect_source_versions(struct distribution *d, struct info_sour
if (last->next == NULL)
break;
last = last->next;
c = strcmp(name, last->name);
c = strcmp(cursor.current.name, last->name);
if (c == 0) {
into = NULL;
break;
......@@ -115,7 +115,7 @@ static retvalue collect_source_versions(struct distribution *d, struct info_sour
into = &root;
while ((last = *into) != NULL) {
int c;
c = strcmp(name, last->name);
c = strcmp(cursor.current.name, last->name);
if (c == 0) {
into = NULL;
break;
......@@ -132,7 +132,7 @@ static retvalue collect_source_versions(struct distribution *d, struct info_sour
result = RET_ERROR_OOM;
break;
}
last->name = strdup(name);
last->name = strdup(cursor.current.name);
if (FAILEDTOALLOC(last->name)) {
free(version);
free(last);
......@@ -146,7 +146,7 @@ static retvalue collect_source_versions(struct distribution *d, struct info_sour
continue;
}
assert (last != NULL);
assert (strcmp(name, last->name)==0);
assert (strcmp(cursor.current.name, last->name)==0);
v = &last->version;
while (strcmp(v->version, version) != 0) {
......@@ -167,7 +167,7 @@ static retvalue collect_source_versions(struct distribution *d, struct info_sour
}
free(version);
}
r = target_closeiterator(&target_cursor);
r = package_closeiterator(&cursor);
if (RET_WAS_ERROR(r)) {
RET_UPDATE(result, r);
break;
......@@ -184,24 +184,24 @@ static retvalue collect_source_versions(struct distribution *d, struct info_sour
static retvalue process_binaries(struct distribution *d, struct info_source *sources, retvalue (*action)(struct distribution *, struct target *, const char *, const char *, const char *, const char *, void *), void *privdata) {
struct target *t;
struct target_cursor target_cursor = TARGET_CURSOR_ZERO;
const char *name, *chunk;
struct package_cursor cursor;
retvalue result = RET_NOTHING, r;
for (t = d->targets ; t != NULL ; t = t->next) {
if (t->architecture == architecture_source)
continue;
r = target_openiterator(t, true, &target_cursor);
r = package_openiterator(t, true, &cursor);
if (RET_WAS_ERROR(r)) {
RET_UPDATE(result, r);
break;
}
while (target_nextpackage(&target_cursor, &name, &chunk)) {
while (package_next(&cursor)) {
char *source, *version;
struct info_source *s;
struct info_source_version *v;
r = t->getsourceandversion(chunk, name,
r = t->getsourceandversion(cursor.current.control,
cursor.current.name,
&source, &version);
if (!RET_IS_OK(r)) {
RET_UPDATE(result, r);
......@@ -221,13 +221,15 @@ static retvalue process_binaries(struct distribution *d, struct info_source *sou
v->used = true;
} else if (action != NULL) {
r = action(d, t,
name, source, version, chunk,
cursor.current.name,
source, version,
cursor.current.control,
privdata);
RET_UPDATE(result, r);
}
free(source); free(version);
}
r = target_closeiterator(&target_cursor);
r = package_closeiterator(&cursor);
if (RET_WAS_ERROR(r)) {
RET_UPDATE(result, r);
break;
......
......@@ -303,12 +303,11 @@ retvalue target_removepackage(struct target *target, struct logger *logger, cons
return r;
}
/* Like target_removepackage, but delete the package record by cursor */
retvalue target_removepackage_by_cursor(struct target_cursor *tc, struct logger *logger, struct trackingdata *trackingdata) {
retvalue package_remove_by_cursor(struct package_cursor *tc, struct logger *logger, struct trackingdata *trackingdata) {
struct target * const target = tc->target;
const char * const name = tc->lastname;
const char * const control = tc->lastcontrol;
const char * const name = tc->current.name;
const char * const control = tc->current.control;
char *oldpversion = NULL;
struct strlist files;
retvalue result, r;
......@@ -340,7 +339,7 @@ retvalue target_removepackage_by_cursor(struct target_cursor *tc, struct logger
if (verbose > 0)
printf("removing '%s' from '%s'...\n",
name, target->identifier);
result = cursor_delete(target->packages, tc->cursor, tc->lastname, NULL);
result = cursor_delete(target->packages, tc->cursor, name, NULL);
if (RET_IS_OK(result)) {
target->wasmodified = true;
if (oldsource != NULL && oldsversion != NULL) {
......@@ -652,8 +651,7 @@ retvalue target_checkaddpackage(struct target *target, const char *name, const c
retvalue target_rereference(struct target *target) {
retvalue result, r;
struct target_cursor iterator;
const char *package, *control;
struct package_cursor iterator;
if (verbose > 1) {
if (verbose > 2)
......@@ -668,20 +666,21 @@ retvalue target_rereference(struct target *target) {
if (verbose > 2)