summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2012-01-16 15:36:54 +0100
committerMichael Schroeder <mls@suse.de>2012-01-16 15:36:54 +0100
commit370badc5cfbd583854222639170b5d0a743b172d (patch)
tree3513b92bb176300e2dc3b80991825dd9c6d0a3e7 /src
parent8736ad5ec8cf65daa6bcf4b505abc0df7485748b (diff)
downloadlibsolv-370badc5cfbd583854222639170b5d0a743b172d.tar.gz
libsolv-370badc5cfbd583854222639170b5d0a743b172d.tar.bz2
libsolv-370badc5cfbd583854222639170b5d0a743b172d.zip
- add missing repo_lookup_deparray/repo_add_deparray/repo_add_idarray/repo_set_deparray/repo_set_idarray (untested)
Diffstat (limited to 'src')
-rw-r--r--src/libsolv.ver5
-rw-r--r--src/repo.c158
-rw-r--r--src/repo.h6
3 files changed, 169 insertions, 0 deletions
diff --git a/src/libsolv.ver b/src/libsolv.ver
index a3e7f26..54e93b8 100644
--- a/src/libsolv.ver
+++ b/src/libsolv.ver
@@ -106,6 +106,8 @@ SOLV_1.0 {
queue_insert;
queue_insert2;
queue_insertn;
+ repo_add_deparray;
+ repo_add_idarray;
repo_add_poolstr_array;
repo_add_repodata;
repo_add_solv;
@@ -126,6 +128,7 @@ SOLV_1.0 {
repo_last_repodata;
repo_lookup_bin_checksum;
repo_lookup_checksum;
+ repo_lookup_deparray;
repo_lookup_id;
repo_lookup_idarray;
repo_lookup_num;
@@ -135,7 +138,9 @@ SOLV_1.0 {
repo_matchvalue;
repo_reserve_ids;
repo_search;
+ repo_set_deparray;
repo_set_id;
+ repo_set_idarray;
repo_set_num;
repo_set_poolstr;
repo_set_str;
diff --git a/src/repo.c b/src/repo.c
index c3767c8..0529681 100644
--- a/src/repo.c
+++ b/src/repo.c
@@ -1206,6 +1206,36 @@ repo_lookup_idarray(Repo *repo, Id entry, Id keyname, Queue *q)
return 0;
}
+int
+repo_lookup_deparray(Repo *repo, Id entry, Id keyname, Queue *q, Id marker)
+{
+ int r = repo_lookup_idarray(repo, entry, keyname, q);
+ if (r && marker)
+ {
+ int i;
+ if (marker < 0)
+ {
+ marker = -marker;
+ for (i = 0; i < q->count; i++)
+ if (q->elements[i] == marker)
+ {
+ queue_truncate(q, i);
+ return r;
+ }
+ }
+ else
+ {
+ for (i = 0; i < q->count; i++)
+ if (q->elements[i] == marker)
+ {
+ queue_deleten(q, 0, i + 1);
+ return r;
+ }
+ }
+ }
+ return r;
+}
+
const unsigned char *
repo_lookup_bin_checksum(Repo *repo, Id entry, Id keyname, Id *typep)
{
@@ -1409,6 +1439,134 @@ repo_add_poolstr_array(Repo *repo, Id p, Id keyname, const char *str)
}
void
+repo_add_deparray(Repo *repo, Id p, Id keyname, Id dep, Id marker)
+{
+ Repodata *data;
+ if (p >= 0)
+ {
+ Solvable *s = repo->pool->solvables + p;
+ switch (keyname)
+ {
+ case SOLVABLE_PROVIDES:
+ s->provides = repo_addid_dep(repo, s->provides, dep, marker);
+ return;
+ case SOLVABLE_OBSOLETES:
+ s->obsoletes = repo_addid_dep(repo, s->obsoletes, dep, marker);
+ return;
+ case SOLVABLE_CONFLICTS:
+ s->conflicts = repo_addid_dep(repo, s->conflicts, dep, marker);
+ return;
+ case SOLVABLE_REQUIRES:
+ s->requires = repo_addid_dep(repo, s->requires, dep, marker);
+ return;
+ case SOLVABLE_RECOMMENDS:
+ s->recommends = repo_addid_dep(repo, s->recommends, dep, marker);
+ return;
+ case SOLVABLE_SUGGESTS:
+ s->suggests = repo_addid_dep(repo, s->suggests, dep, marker);
+ return;
+ case SOLVABLE_SUPPLEMENTS:
+ s->supplements = repo_addid_dep(repo, s->supplements, dep, marker);
+ return;
+ case SOLVABLE_ENHANCES:
+ s->enhances = repo_addid_dep(repo, s->enhances, dep, marker);
+ return;
+ }
+ }
+ data = repo_last_repodata(repo);
+ repodata_add_idarray(data, p, keyname, dep);
+}
+
+void
+repo_add_idarray(Repo *repo, Id p, Id keyname, Id id)
+{
+ repo_add_deparray(repo, p, keyname, id, 0);
+}
+
+static Offset
+repo_set_idarray_solvable(Repo *repo, Queue *q)
+{
+ Offset o = 0;
+ int i;
+ for (i = 0; i < q->count; i++)
+ repo_addid_dep(repo, o, q->elements[i], 0);
+ return o;
+}
+
+void
+repo_set_deparray(Repo *repo, Id p, Id keyname, Queue *q, Id marker)
+{
+ Repodata *data;
+ if (marker)
+ {
+ /* complex case, splice old and new arrays */
+ int i;
+ Queue q2;
+ queue_init(&q2);
+ repo_lookup_deparray(repo, p, keyname, &q2, -marker);
+ if (marker > 0)
+ {
+ if (q->count)
+ {
+ queue_push(&q2, marker);
+ for (i = 0; i < q->count; i++)
+ queue_push(&q2, q->elements[i]);
+ }
+ }
+ else
+ {
+ if (q2.count)
+ queue_insert(&q2, 0, -marker);
+ queue_insertn(&q2, 0, q->count);
+ for (i = 0; i < q->count; i++)
+ q2.elements[i] = q->elements[i];
+ }
+ repo_set_deparray(repo, p, keyname, &q2, 0);
+ queue_free(&q2);
+ return;
+ }
+ if (p >= 0)
+ {
+ Solvable *s = repo->pool->solvables + p;
+ switch (keyname)
+ {
+ case SOLVABLE_PROVIDES:
+ s->provides = repo_set_idarray_solvable(repo, q);
+ return;
+ case SOLVABLE_OBSOLETES:
+ s->obsoletes = repo_set_idarray_solvable(repo, q);
+ return;
+ case SOLVABLE_CONFLICTS:
+ s->conflicts = repo_set_idarray_solvable(repo, q);
+ return;
+ case SOLVABLE_REQUIRES:
+ s->requires = repo_set_idarray_solvable(repo, q);
+ return;
+ case SOLVABLE_RECOMMENDS:
+ s->recommends = repo_set_idarray_solvable(repo, q);
+ return;
+ case SOLVABLE_SUGGESTS:
+ s->suggests = repo_set_idarray_solvable(repo, q);
+ return;
+ case SOLVABLE_SUPPLEMENTS:
+ s->supplements = repo_set_idarray_solvable(repo, q);
+ return;
+ case SOLVABLE_ENHANCES:
+ s->enhances = repo_set_idarray_solvable(repo, q);
+ return;
+ }
+ }
+ data = repo_last_repodata(repo);
+ repodata_set_idarray(data, p, keyname, q);
+}
+
+void
+repo_set_idarray(Repo *repo, Id p, Id keyname, Queue *q)
+{
+ repo_set_deparray(repo, p, keyname, q, 0);
+}
+
+void
repo_internalize(Repo *repo)
{
int i;
diff --git a/src/repo.h b/src/repo.h
index ffc71d8..7be3beb 100644
--- a/src/repo.h
+++ b/src/repo.h
@@ -178,6 +178,7 @@ const char *repo_lookup_str(Repo *repo, Id entry, Id keyname);
unsigned int repo_lookup_num(Repo *repo, Id entry, Id keyname, unsigned int notfound);
Id repo_lookup_id(Repo *repo, Id entry, Id keyname);
int repo_lookup_idarray(Repo *repo, Id entry, Id keyname, Queue *q);
+int repo_lookup_deparray(Repo *repo, Id entry, Id keyname, Queue *q, Id marker);
int repo_lookup_void(Repo *repo, Id entry, Id keyname);
const char *repo_lookup_checksum(Repo *repo, Id entry, Id keyname, Id *typep);
const unsigned char *repo_lookup_bin_checksum(Repo *repo, Id entry, Id keyname, Id *typep);
@@ -293,6 +294,11 @@ void repo_set_num(Repo *repo, Id p, Id keyname, unsigned int num);
void repo_set_str(Repo *repo, Id p, Id keyname, const char *str);
void repo_set_poolstr(Repo *repo, Id p, Id keyname, const char *str);
void repo_add_poolstr_array(Repo *repo, Id p, Id keyname, const char *str);
+void repo_add_idarray(Repo *repo, Id p, Id keyname, Id id);
+void repo_add_deparray(Repo *repo, Id p, Id keyname, Id dep, Id marker);
+void repo_set_idarray(Repo *repo, Id p, Id keyname, Queue *q);
+void repo_set_deparray(Repo *repo, Id p, Id keyname, Queue *q, Id marker);
+
void repo_internalize(Repo *repo);
void repo_disable_paging(Repo *repo);