Author: dmacvicar Date: Wed Feb 6 03:08:15 2008 New Revision: 8488 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8488&view=rev Log: expose repo_lookup_str and add lookup_num (nonworking) Modified: trunk/sat-solver/src/repo.c trunk/sat-solver/src/repo.h trunk/sat-solver/src/repodata.c trunk/sat-solver/src/repodata.h Modified: trunk/sat-solver/src/repo.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo.c?rev=8488&r1=8487&r2=8488&view=diff ============================================================================== --- trunk/sat-solver/src/repo.c (original) +++ trunk/sat-solver/src/repo.c Wed Feb 6 03:08:15 2008 @@ -766,6 +766,28 @@ return 0; } +int +repo_lookup_num(Solvable *s, Id key) +{ + Repo *repo = s->repo; + Pool *pool = repo->pool; + Repodata *data; + int i, j, n; + + n = s - pool->solvables; + for (i = 0, data = repo->repodata; i < repo->nrepodata; i++, data++) + { + if (n < data->start || n >= data->end) + continue; + for (j = 1; j < data->nkeys; j++) + { + if (data->keys[j].name == key && (data->keys[j].type == TYPE_U32 || data->keys[j].type == TYPE_NUM)) + return repodata_lookup_num(data, n - data->start, j); + } + } + return 0; +} + Repodata * repo_add_repodata(Repo *repo) { Modified: trunk/sat-solver/src/repo.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo.h?rev=8488&r1=8487&r2=8488&view=diff ============================================================================== --- trunk/sat-solver/src/repo.h (original) +++ trunk/sat-solver/src/repo.h Wed Feb 6 03:08:15 2008 @@ -163,6 +163,11 @@ Repodata *repo_add_repodata(Repo *repo); void repo_search(Repo *repo, Id p, Id key, const char *match, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *kv), void *cbdata); +/* returns the string value of the attribute, or NULL if not found */ +const char * repo_lookup_str(Solvable *s, Id key); +/* returns the string value of the attribute, or 0 if not found */ +int repo_lookup_num(Solvable *s, Id key); + void repo_set_id(Repo *repo, Id p, Id keyname, Id id); void repo_set_num(Repo *repo, Id p, Id keyname, Id num); void repo_set_str(Repo *repo, Id p, Id keyname, const char *str); Modified: trunk/sat-solver/src/repodata.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repodata.c?rev=8488&r1=8487&r2=8488&view=diff ============================================================================== --- trunk/sat-solver/src/repodata.c (original) +++ trunk/sat-solver/src/repodata.c Wed Feb 6 03:08:15 2008 @@ -430,6 +430,34 @@ return id2str(data->repo->pool, id); } +int +repodata_lookup_num(Repodata *data, Id entry, Id keyid) +{ + Id schema; + Repokey *key; + Id *keyp; + KeyValue kv; + unsigned char *dp; + + dp = data->incoredata + data->incoreoffset[entry]; + dp = data_read_id(dp, &schema); + /* make sure the schema of this solvable contains the key */ + for (keyp = data->schemadata + data->schemata[schema]; *keyp != keyid; keyp++) + if (!*keyp) + return 0; + dp = forward_to_key(data, keyid, schema, dp); + key = data->keys + keyid; + dp = get_data(data, key, &dp); + if (!dp) + return 0; + if (key->type == TYPE_NUM || key->type == TYPE_U32) + { + dp = data_fetch(dp, &kv, key); + return kv.num; + } + return 0; +} + void repodata_search(Repodata *data, Id entry, Id keyname, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *kv), void *cbdata) { Modified: trunk/sat-solver/src/repodata.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repodata.h?rev=8488&r1=8487&r2=8488&view=diff ============================================================================== --- trunk/sat-solver/src/repodata.h (original) +++ trunk/sat-solver/src/repodata.h Wed Feb 6 03:08:15 2008 @@ -101,6 +101,7 @@ void repodata_search(Repodata *data, Id entry, Id keyname, int (*callback)(void *cbdata, Solvable *s, Repodata *data, struct _Repokey *key, struct _KeyValue *kv), void *cbdata); const char *repodata_lookup_str(Repodata *data, Id entry, Id keyid); +int repodata_lookup_num(Repodata *data, Id entry, Id keyid); void repodata_extend(Repodata *data, Id p); -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org