ref: refs/heads/master
commit edb407779d635b16d8e4fbc265f51b7fd347a1df
Author: Michael Schroeder
Date: Thu Jul 2 12:34:16 2009 +0200
- clonepos didn't clne nparents
- add dataiterator_set_search
- add dataiterator_set_keyname
- add dataiterator_set_match
---
src/repo.h | 7 ++++-
src/repodata.c | 61 ++++++++++++++++++++++++++++++++++++++++++++------------
2 files changed, 53 insertions(+), 15 deletions(-)
diff --git a/src/repo.h b/src/repo.h
index e0b7685..fe2c3ec 100644
--- a/src/repo.h
+++ b/src/repo.h
@@ -263,8 +263,11 @@ int datamatcher_match(Datamatcher *ma, const char *str);
* keyname: if non-null, limit search to this keyname
* match: if non-null, limit search to this match
*/
-int dataiterator_init(Dataiterator *di, Pool *pool, Repo *repo, Id p, Id keyname,
- const char *match, int flags);
+int dataiterator_init(Dataiterator *di, Pool *pool, Repo *repo, Id p, Id keyname, const char *match, int flags);
+void dataiterator_set_search(Dataiterator *di, Repo *repo, Id p);
+void dataiterator_set_keyname(Dataiterator *di, Id keyname);
+int dataiterator_set_match(Dataiterator *di, const char *match, int flags);
+
void dataiterator_prepend_keyname(Dataiterator *di, Id keyname);
void dataiterator_free(Dataiterator *di);
int dataiterator_step(Dataiterator *di);
diff --git a/src/repodata.c b/src/repodata.c
index 15ca6e6..5467e5b 100644
--- a/src/repodata.c
+++ b/src/repodata.c
@@ -982,26 +982,60 @@ dataiterator_init(Dataiterator *di, Pool *pool, Repo *repo, Id p, Id keyname, co
return error;
}
}
- di->repo = repo;
di->keyname = keyname;
di->keynames[0] = keyname;
- di->flags = flags & ~SEARCH_THISSOLVID;
- if (!pool->nrepos)
+ dataiterator_set_search(di, repo, p);
+ return 0;
+}
+
+int
+dataiterator_set_match(Dataiterator *di, const char *match, int flags)
+{
+ di->flags = (flags & ~SEARCH_THISSOLVID) | (di->flags & SEARCH_THISSOLVID);
+ datamatcher_free(&di->matcher);
+ memset(&di->matcher, 0, sizeof(di->matcher));
+ if (match)
+ {
+ int error;
+ if ((error = datamatcher_init(&di->matcher, match, flags)) != 0)
+ {
+ di->state = di_bye;
+ return error;
+ }
+ }
+ return 0;
+}
+
+void
+dataiterator_set_search(Dataiterator *di, Repo *repo, Id p)
+{
+ di->repo = repo;
+ di->repoid = -1;
+ di->flags &= ~SEARCH_THISSOLVID;
+ di->nparents = 0;
+ di->rootlevel = 0;
+ di->repodataid = 0;
+ if (!di->pool->nrepos)
{
di->state = di_bye;
- return 0;
+ return;
}
- if (repo)
- di->repoid = -1;
- if (p)
- dataiterator_jump_to_solvid(di, p);
- else
+ if (!repo)
{
- if (!di->repo)
- di->repo = pool->repos[0];
- di->state = di_enterrepo;
+ di->repoid = 0;
+ di->repo = di->pool->repos[0];
}
- return 0;
+ di->state = di_enterrepo;
+ if (p)
+ dataiterator_jump_to_solvid(di, p);
+}
+
+void
+dataiterator_set_keyname(Dataiterator *di, Id keyname)
+{
+ di->nkeynames = 0;
+ di->keyname = keyname;
+ di->keynames[0] = keyname;
}
void
@@ -1341,6 +1375,7 @@ dataiterator_clonepos(Dataiterator *di, Dataiterator *from)
di->repoid = from->repoid;
di->rootlevel = from->rootlevel;
memcpy(di->parents, from->parents, sizeof(from->parents));
+ di->nparents = from->nparents;
if (di->nparents)
{
int i;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org