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 _Repokey {
27 #define KEY_STORAGE_DROPPED 0
28 #define KEY_STORAGE_SOLVABLE 1
29 #define KEY_STORAGE_INCORE 2
30 #define KEY_STORAGE_VERTICAL_OFFSET 3
34 typedef struct _Repodata {
35 struct _Repo *repo; /* back pointer to repo */
37 int start; /* start of solvables this repodata is valid for */
38 int end; /* last solvable + 1 of this repodata */
40 /* Keys provided by this attribute store, sorted by name value.
41 The same keys may be provided by multiple attribute stores, but
42 then only for different solvables. I.e. the relation
43 (solvable,name) -> store
44 has to be injective. */
46 Repokey *keys; /* keys, first entry is always zero */
47 unsigned int nkeys; /* length of keys array */
49 Id *schemata; /* schema -> offset into schemadata */
50 unsigned int nschemata; /* number of schemata */
52 Id *schemadata; /* schema storage */
54 unsigned char *entryschemau8; /* schema for entry */
55 Id *entryschema; /* schema for entry */
57 unsigned char *incoredata; /* in-core data */
58 unsigned int incoredatalen; /* data len */
59 unsigned int incoredatafree; /* data len */
61 Id *incoreoffset; /* offset for all entries */
63 FILE *fp; /* for paged access */
64 Id verticaloffset; /* offset of verticals */
70 /* The attribute store itself. */
72 /* A filename where to find this attribute store, or where to store
73 it. May be "", in which case we can't load it on demand or store
74 into it. It may also be NULL for at most one of the repodata per
75 repo, in which case these are the embedded attributes. */
78 /* The SHA1 checksum of the file. */
79 unsigned char checksum[20];
83 typedef struct _Repo {
85 struct _Pool *pool; /* pool containing repo data */
87 int start; /* start of this repo solvables within pool->solvables */
88 int end; /* last solvable + 1 of this repo */
89 int nsolvables; /* number of solvables repo is contributing to pool */
91 int priority; /* priority of this repo */
93 Id *idarraydata; /* array of metadata Ids, solvable dependencies are offsets into this array */
99 /* The attribute stores we know about. */
101 /* Number of attribute stores.. */
105 extern Repo *repo_create(Pool *pool, const char *name);
106 extern void repo_free(Repo *repo, int reuseids);
107 extern void repo_freeallrepos(Pool *pool, int reuseids);
109 extern Offset repo_addid(Repo *repo, Offset olddeps, Id id);
110 extern Offset repo_addid_dep(Repo *repo, Offset olddeps, Id id, int isreq);
111 extern Offset repo_reserve_ids(Repo *repo, Offset olddeps, int num);
112 extern Offset repo_fix_legacy(Repo *repo, Offset provides, Offset supplements);
114 extern void repo_add_attrstore (Repo *repo, Attrstore *s, const char *location);
116 static inline const char *repo_name(const Repo *repo)
121 static inline Id repo_add_solvable(Repo *repo)
123 extern Id pool_add_solvable(Pool *pool);
124 Id p = pool_add_solvable(repo->pool);
125 if (!repo->start || repo->start == repo->end)
134 if (p + 1 > repo->end)
138 repo->pool->solvables[p].repo = repo;
142 static inline Id repo_add_solvable_block(Repo *repo, int count)
144 extern Id pool_add_solvable_block(Pool *pool, int count);
149 p = pool_add_solvable_block(repo->pool, count);
150 if (!repo->start || repo->start == repo->end)
153 repo->end = p + count;
159 if (p + count > repo->end)
160 repo->end = p + count;
162 repo->nsolvables += count;
163 for (s = repo->pool->solvables + p; count--; s++)
168 static inline void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids)
170 extern void pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids);
173 if (start + count == repo->end)
175 repo->nsolvables -= count;
176 for (s = repo->pool->solvables + start, i = count; i--; s++)
178 pool_free_solvable_block(repo->pool, start, count, reuseids);
181 #define FOR_REPO_SOLVABLES(r, p, s) \
182 for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s++) \
185 #endif /* SATSOLVER_REPO_H */