2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
13 #ifndef LIBSOLV_REPO_H
14 #define LIBSOLV_REPO_H
16 #include "pooltypes.h"
19 #include "dataiterator.h"
24 typedef struct _Repo {
25 const char *name; /* name pointer */
26 Id repoid; /* our id */
27 void *appdata; /* application private pointer */
29 Pool *pool; /* pool containing this repo */
31 int start; /* start of this repo solvables within pool->solvables */
32 int end; /* last solvable + 1 of this repo */
33 int nsolvables; /* number of solvables repo is contributing to pool */
35 int disabled; /* ignore the solvables? */
36 int priority; /* priority of this repo */
37 int subpriority; /* sub-priority of this repo, used just for sorting, not pruning */
39 Id *idarraydata; /* array of metadata Ids, solvable dependencies are offsets into this array */
42 unsigned nrepodata; /* number of our stores.. */
44 Id *rpmdbid; /* solvable side data: rpm database id */
46 #ifdef LIBSOLV_INTERNAL
47 Repodata *repodata; /* our stores for non-solvable related data */
48 Offset lastoff; /* start of last array in idarraydata */
50 Hashtable lastidhash; /* hash to speed up repo_addid_dep */
51 Hashmask lastidhash_mask;
52 int lastidhash_idarraysize;
55 #endif /* LIBSOLV_INTERNAL */
58 extern Repo *repo_create(Pool *pool, const char *name);
59 extern void repo_free(Repo *repo, int reuseids);
60 extern void repo_empty(Repo *repo, int reuseids);
61 extern void repo_freedata(Repo *repo);
62 extern Id repo_add_solvable(Repo *repo);
63 extern Id repo_add_solvable_block(Repo *repo, int count);
64 extern void repo_free_solvable(Repo *repo, Id p, int reuseids);
65 extern void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids);
66 extern void *repo_sidedata_create(Repo *repo, size_t size);
67 extern void *repo_sidedata_extend(Repo *repo, void *b, size_t size, Id p, int count);
69 extern Offset repo_addid(Repo *repo, Offset olddeps, Id id);
70 extern Offset repo_addid_dep(Repo *repo, Offset olddeps, Id id, Id marker);
71 extern Offset repo_reserve_ids(Repo *repo, Offset olddeps, int num);
72 extern Offset repo_fix_supplements(Repo *repo, Offset provides, Offset supplements, Offset freshens);
73 extern Offset repo_fix_conflicts(Repo *repo, Offset conflicts);
75 static inline const char *repo_name(const Repo *repo)
80 /* those two functions are here because they need the Repo definition */
82 static inline Repo *pool_id2repo(Pool *pool, Id repoid)
84 return repoid < pool->nrepos ? pool->repos[repoid] : 0;
87 static inline int pool_installable(const Pool *pool, Solvable *s)
89 if (!s->arch || s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
91 if (s->repo && s->repo->disabled)
93 if (pool->id2arch && (s->arch > pool->lastarch || !pool->id2arch[s->arch]))
97 Id id = s - pool->solvables;
98 if (!MAPTST(pool->considered, id))
104 /* search callback values */
105 #define SEARCH_NEXT_KEY 1
106 #define SEARCH_NEXT_SOLVABLE 2
107 #define SEARCH_STOP 3
108 #define SEARCH_ENTERSUB -1
110 /* standard flags used in the repo_add functions */
111 #define REPO_REUSE_REPODATA (1 << 0)
112 #define REPO_NO_INTERNALIZE (1 << 1)
113 #define REPO_LOCALPOOL (1 << 2)
114 #define REPO_USE_LOADING (1 << 3)
115 #define REPO_EXTEND_SOLVABLES (1 << 4)
116 #define REPO_USE_ROOTDIR (1 << 5)
118 Repodata *repo_add_repodata(Repo *repo, int flags);
119 Repodata *repo_id2repodata(Repo *repo, Id id);
120 Repodata *repo_last_repodata(Repo *repo);
122 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);
124 /* returns the string value of the attribute, or NULL if not found */
125 Id repo_lookup_type(Repo *repo, Id entry, Id keyname);
126 const char *repo_lookup_str(Repo *repo, Id entry, Id keyname);
127 /* returns the integer value of the attribute, or notfound if not found */
128 unsigned long long repo_lookup_num(Repo *repo, Id entry, Id keyname, unsigned long long notfound);
129 Id repo_lookup_id(Repo *repo, Id entry, Id keyname);
130 int repo_lookup_idarray(Repo *repo, Id entry, Id keyname, Queue *q);
131 int repo_lookup_deparray(Repo *repo, Id entry, Id keyname, Queue *q, Id marker);
132 int repo_lookup_void(Repo *repo, Id entry, Id keyname);
133 const char *repo_lookup_checksum(Repo *repo, Id entry, Id keyname, Id *typep);
134 const unsigned char *repo_lookup_bin_checksum(Repo *repo, Id entry, Id keyname, Id *typep);
136 void repo_set_id(Repo *repo, Id p, Id keyname, Id id);
137 void repo_set_num(Repo *repo, Id p, Id keyname, unsigned long long num);
138 void repo_set_str(Repo *repo, Id p, Id keyname, const char *str);
139 void repo_set_poolstr(Repo *repo, Id p, Id keyname, const char *str);
140 void repo_add_poolstr_array(Repo *repo, Id p, Id keyname, const char *str);
141 void repo_add_idarray(Repo *repo, Id p, Id keyname, Id id);
142 void repo_add_deparray(Repo *repo, Id p, Id keyname, Id dep, Id marker);
143 void repo_set_idarray(Repo *repo, Id p, Id keyname, Queue *q);
144 void repo_set_deparray(Repo *repo, Id p, Id keyname, Queue *q, Id marker);
145 void repo_set_deleted(Repo *repo, Id p, Id keyname);
147 void repo_internalize(Repo *repo);
148 void repo_disable_paging(Repo *repo);
150 /* iterator macros */
151 #define FOR_REPO_SOLVABLES(r, p, s) \
152 for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s = (r)->pool->solvables + p) \
153 if (s->repo != (r)) \
157 #ifdef LIBSOLV_INTERNAL
158 #define FOR_REPODATAS(repo, rdid, data) \
159 for (rdid = 1, data = repo->repodata + rdid; rdid < repo->nrepodata; rdid++, data++)
161 #define FOR_REPODATAS(repo, rdid, data) \
162 for (rdid = 1; rdid < repo->nrepodata && (data = repo_id2repodata(repo, rdid)); rdid++)
165 #endif /* LIBSOLV_REPO_H */