2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
13 #ifndef SATSOLVER_REPO_H
14 #define SATSOLVER_REPO_H
16 #include "pooltypes.h"
18 #include "attr_store.h"
20 typedef struct _Repodata {
21 /* Keys provided by this attribute store, sorted by name value.
22 The same keys may be provided by multiple attribute stores, but
23 then only for different solvables. I.e. the relation
24 (solvable,name) -> store
25 has to be injective. */
30 /* Length of keys array */
33 /* The attribute store itself. */
35 /* A filename where to find this attribute store, or where to store
36 it. May be "", in which case we can't load it on demand or store
37 into it. It may also be NULL for at most one of the repodata per
38 repo, in which case these are the embedded attributes. */
41 /* The SHA1 checksum of the file. */
42 unsigned char checksum[20];
45 typedef struct _Repo {
47 struct _Pool *pool; /* pool containing repo data */
48 int start; /* start of this repo solvables within pool->solvables */
49 int end; /* last solvable + 1 of this repo */
50 int nsolvables; /* number of solvables repo is contributing to pool */
52 int priority; /* priority of this repo */
54 Id *idarraydata; /* array of metadata Ids, solvable dependencies are offsets into this array */
60 /* The attribute stores we know about. */
62 /* Number of attribute stores.. */
66 extern Repo *repo_create(Pool *pool, const char *name);
67 extern void repo_free(Repo *repo, int reuseids);
68 extern void repo_freeallrepos(Pool *pool, int reuseids);
70 extern Offset repo_addid(Repo *repo, Offset olddeps, Id id);
71 extern Offset repo_addid_dep(Repo *repo, Offset olddeps, Id id, int isreq);
72 extern Offset repo_reserve_ids(Repo *repo, Offset olddeps, int num);
73 extern Offset repo_fix_legacy(Repo *repo, Offset provides, Offset supplements);
75 extern void repo_add_attrstore (Repo *repo, Attrstore *s, const char *location);
77 static inline const char *repo_name(const Repo *repo)
82 static inline Id repo_add_solvable(Repo *repo)
84 extern Id pool_add_solvable(Pool *pool);
85 Id p = pool_add_solvable(repo->pool);
86 if (!repo->start || repo->start == repo->end)
95 if (p + 1 > repo->end)
99 repo->pool->solvables[p].repo = repo;
103 static inline Id repo_add_solvable_block(Repo *repo, int count)
105 extern Id pool_add_solvable_block(Pool *pool, int count);
110 p = pool_add_solvable_block(repo->pool, count);
111 if (!repo->start || repo->start == repo->end)
114 repo->end = p + count;
120 if (p + count > repo->end)
121 repo->end = p + count;
123 repo->nsolvables += count;
124 for (s = repo->pool->solvables + p; count--; s++)
129 static inline void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids)
131 extern void pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids);
134 if (start + count == repo->end)
136 repo->nsolvables -= count;
137 for (s = repo->pool->solvables + start, i = count; i--; s++)
139 pool_free_solvable_block(repo->pool, start, count, reuseids);
142 #define FOR_REPO_SOLVABLES(r, p, s) \
143 for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s++) \
146 #endif /* SATSOLVER_REPO_H */