return 0;
}
+Id
+repodata_lookup_id(Repodata *data, Id entry, Id keyid)
+{
+ Id schema;
+ Repokey *key;
+ Id id, *keyp;
+ unsigned char *dp;
+
+ if (!maybe_load_repodata(data, &keyid))
+ return 0;
+ 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 == REPOKEY_TYPE_CONSTANTID)
+ return key->size;
+ if (key->type != REPOKEY_TYPE_ID)
+ return 0;
+ dp = data_read_id(dp, &id);
+ return id;
+}
+
const char *
repodata_lookup_str(Repodata *data, Id entry, Id keyid)
{
Id *addedfileprovides;
} Repodata;
+/* management functions */
+void repodata_init(Repodata *data, struct _Repo *repo, int localpool);
+void repodata_extend(Repodata *data, Id p);
+void repodata_extend_block(Repodata *data, Id p, int num);
+void repodata_free(Repodata *data);
+
/* Search key <keyname> (all keys, if keyname == 0) for Id <entry>
* <entry> is _relative_ Id for <data>
* Call <callback> for each match
*/
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);
-/*
- * lookup string type attribute
- */
+/* lookup functions */
+Id repodata_lookup_id(Repodata *data, Id entry, Id keyid);
const char *repodata_lookup_str(Repodata *data, Id entry, Id keyid);
-
-/*
- * lookup integer type attribute
- */
int repodata_lookup_num(Repodata *data, Id entry, Id keyid, unsigned *value);
int repodata_lookup_void(Repodata *data, Id entry, Id keyid);
const unsigned char *repodata_lookup_bin_checksum(Repodata *data, Id entry, Id keyid, Id *typep);
-void repodata_init(Repodata *data, struct _Repo *repo, int localpool);
-void repodata_extend(Repodata *data, Id p);
-void repodata_extend_block(Repodata *data, Id p, int num);
-void repodata_free(Repodata *data);
-
+/* data assignment */
void repodata_set_id(Repodata *data, Id entry, Id keyname, Id id);
void repodata_set_num(Repodata *data, Id entry, Id keyname, Id num);
void repodata_set_poolstr(Repodata *data, Id entry, Id keyname, const char *str);
void repodata_internalize(Repodata *data);
void repodata_disable_paging(Repodata *data);
+/* helper functions */
+Id repodata_globalize_id(Repodata *data, Id id);
Id repodata_str2dir(Repodata *data, const char *dir, int create);
const char *repodata_dir2str(Repodata *data, Id did, const char *suf);
const char *repodata_chk2str(Repodata *data, Id type, const unsigned char *buf);
+/* internal */
unsigned int repodata_compress_page(unsigned char *, unsigned int, unsigned char *, unsigned int);
void repodata_read_or_setup_pages(Repodata *data, unsigned int pagesz, unsigned int blobsz);
-Id repodata_globalize_id(Repodata *data, Id id);
#endif /* SATSOLVER_REPODATA_H */
return p;
}
+Id
+solvable_lookup_id(Solvable *s, Id keyname)
+{
+ Repo *repo = s->repo;
+ Pool *pool;
+ Repodata *data;
+ int i, j, n;
+
+ if (!repo)
+ return 0;
+ pool = repo->pool;
+ switch(keyname)
+ {
+ case SOLVABLE_NAME:
+ return s->name;
+ case SOLVABLE_ARCH:
+ return s->arch;
+ case SOLVABLE_EVR:
+ return s->evr;
+ case SOLVABLE_VENDOR:
+ return s->vendor;
+ }
+ 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 == keyname && (data->keys[j].type == REPOKEY_TYPE_ID || data->keys[j].type == REPOKEY_TYPE_CONSTANTID))
+ {
+ Id id = repodata_lookup_id(data, n - data->start, j);
+ if (id)
+ {
+ if (data->localpool)
+ id = repodata_globalize_id(data, id);
+ return id;
+ }
+ }
+ }
+ }
+ return 0;
+}
+
const char *
solvable_lookup_str(Solvable *s, Id keyname)
{