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 FILE *fp; /* file pointer of solv file */
41 int error; /* corrupt solv file */
43 /* Keys provided by this attribute store, sorted by name value.
44 The same keys may be provided by multiple attribute stores, but
45 then only for different solvables. I.e. the relation
46 (solvable,name) -> store
47 has to be injective. */
49 Repokey *keys; /* keys, first entry is always zero */
50 unsigned int nkeys; /* length of keys array */
52 Id *schemata; /* schema -> offset into schemadata */
53 unsigned int nschemata; /* number of schemata */
55 Id *schemadata; /* schema storage */
57 unsigned char *entryschemau8; /* schema for entry */
58 Id *entryschema; /* schema for entry */
60 unsigned char *incoredata; /* in-core data (flat_attrs) */
61 unsigned int incoredatalen; /* data len (attr_next_free) */
62 unsigned int incoredatafree; /* free data len */
64 Id *incoreoffset; /* offset for all entries (ent2attr) */
66 Id verticaloffset; /* file offset of verticals */
67 char *strbuf; /* just for testing */
68 int strbuflen; /* just for testing */
71 /* The attribute store itself. */
73 /* A filename where to find this attribute store, or where to store
74 it. May be "", in which case we can't load it on demand or store
75 into it. It may also be NULL for at most one of the repodata per
76 repo, in which case these are the embedded attributes. */
79 /* The SHA1 checksum of the file. */
80 unsigned char checksum[20];
84 typedef struct _Repo {
86 struct _Pool *pool; /* pool containing repo data */
88 int start; /* start of this repo solvables within pool->solvables */
89 int end; /* last solvable + 1 of this repo */
90 int nsolvables; /* number of solvables repo is contributing to pool */
92 int priority; /* priority of this repo */
94 Id *idarraydata; /* array of metadata Ids, solvable dependencies are offsets into this array */
100 /* The attribute stores we know about. */
102 /* Number of attribute stores.. */
106 extern Repo *repo_create(Pool *pool, const char *name);
107 extern void repo_free(Repo *repo, int reuseids);
108 extern void repo_freeallrepos(Pool *pool, int reuseids);
110 extern Offset repo_addid(Repo *repo, Offset olddeps, Id id);
111 extern Offset repo_addid_dep(Repo *repo, Offset olddeps, Id id, Id marker);
112 extern Offset repo_reserve_ids(Repo *repo, Offset olddeps, int num);
113 extern Offset repo_fix_legacy(Repo *repo, Offset provides, Offset supplements);
115 extern void repo_add_attrstore (Repo *repo, Attrstore *s, const char *location);
117 static inline const char *repo_name(const Repo *repo)
122 static inline Id repo_add_solvable(Repo *repo)
124 extern Id pool_add_solvable(Pool *pool);
125 Id p = pool_add_solvable(repo->pool);
126 if (!repo->start || repo->start == repo->end)
135 if (p + 1 > repo->end)
139 repo->pool->solvables[p].repo = repo;
143 static inline Id repo_add_solvable_block(Repo *repo, int count)
145 extern Id pool_add_solvable_block(Pool *pool, int count);
150 p = pool_add_solvable_block(repo->pool, count);
151 if (!repo->start || repo->start == repo->end)
154 repo->end = p + count;
160 if (p + count > repo->end)
161 repo->end = p + count;
163 repo->nsolvables += count;
164 for (s = repo->pool->solvables + p; count--; s++)
169 static inline void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids)
171 extern void pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids);
174 if (start + count == repo->end)
176 repo->nsolvables -= count;
177 for (s = repo->pool->solvables + start, i = count; i--; s++)
179 pool_free_solvable_block(repo->pool, start, count, reuseids);
182 #define FOR_REPO_SOLVABLES(r, p, s) \
183 for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s++) \
186 #endif /* SATSOLVER_REPO_H */