*
*/
-#ifndef SATSOLVER_REPO_H
-#define SATSOLVER_REPO_H
-
-#include <regex.h>
+#ifndef LIBSOLV_REPO_H
+#define LIBSOLV_REPO_H
#include "pooltypes.h"
#include "pool.h"
#include "repodata.h"
+#include "dataiterator.h"
+#include "hash.h"
-typedef struct _Repokey {
- Id name;
- Id type; /* REPOKEY_TYPE_xxx */
- unsigned int size;
- unsigned int storage; /* KEY_STORAGE_xxx */
-} Repokey;
-
-#define KEY_STORAGE_DROPPED 0
-#define KEY_STORAGE_SOLVABLE 1
-#define KEY_STORAGE_INCORE 2
-#define KEY_STORAGE_VERTICAL_OFFSET 3
typedef struct _Repo {
- const char *name;
- struct _Pool *pool; /* pool containing repo data */
+ const char *name; /* name pointer */
+ Id repoid; /* our id */
+ void *appdata; /* application private pointer */
+
+ Pool *pool; /* pool containing this repo */
int start; /* start of this repo solvables within pool->solvables */
int end; /* last solvable + 1 of this repo */
int nsolvables; /* number of solvables repo is contributing to pool */
- int nextra; /* number of extra objects (non-solvables) */
+ int disabled; /* ignore the solvables? */
int priority; /* priority of this repo */
+ int subpriority; /* sub-priority of this repo, used just for sorting, not pruning */
Id *idarraydata; /* array of metadata Ids, solvable dependencies are offsets into this array */
int idarraysize;
- Offset lastoff;
- Id *rpmdbid; /* hmm, go to repodata? */
- unsigned char rpmdbcookie[32];
+ unsigned nrepodata; /* number of our stores.. */
+ Id *rpmdbid; /* solvable side data: rpm database id */
+
+#ifdef LIBSOLV_INTERNAL
Repodata *repodata; /* our stores for non-solvable related data */
- unsigned nrepodata; /* number of our stores.. */
+ Offset lastoff; /* start of last array in idarraydata */
+
+ Hashtable lastidhash; /* hash to speed up repo_addid_dep */
+ Hashmask lastidhash_mask;
+ int lastidhash_idarraysize;
+ int lastmarker;
+ Offset lastmarkerpos;
+#endif /* LIBSOLV_INTERNAL */
} Repo;
extern Repo *repo_create(Pool *pool, const char *name);
extern void repo_free(Repo *repo, int reuseids);
-extern void repo_freeallrepos(Pool *pool, int reuseids);
+extern void repo_empty(Repo *repo, int reuseids);
+extern void repo_freedata(Repo *repo);
+extern Id repo_add_solvable(Repo *repo);
+extern Id repo_add_solvable_block(Repo *repo, int count);
+extern void repo_free_solvable(Repo *repo, Id p, int reuseids);
+extern void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids);
+extern void *repo_sidedata_create(Repo *repo, size_t size);
+extern void *repo_sidedata_extend(Repo *repo, void *b, size_t size, Id p, int count);
extern Offset repo_addid(Repo *repo, Offset olddeps, Id id);
extern Offset repo_addid_dep(Repo *repo, Offset olddeps, Id id, Id marker);
return repo->name;
}
-static inline Id repo_add_solvable(Repo *repo)
+/* those two functions are here because they need the Repo definition */
+
+static inline Repo *pool_id2repo(Pool *pool, Id repoid)
{
- extern Id pool_add_solvable(Pool *pool);
- Id p = pool_add_solvable(repo->pool);
- if (!repo->start || repo->start == repo->end)
- {
- repo->start = p;
- repo->end = p + 1;
- }
- else
- {
- if (p < repo->start)
- repo->start = p;
- if (p + 1 > repo->end)
- repo->end = p + 1;
- }
- repo->nsolvables++;
- repo->pool->solvables[p].repo = repo;
- return p;
+ return repoid < pool->nrepos ? pool->repos[repoid] : 0;
}
-static inline Id repo_add_solvable_block(Repo *repo, int count)
+static inline int pool_installable(const Pool *pool, Solvable *s)
{
- extern Id pool_add_solvable_block(Pool *pool, int count);
- Id p;
- Solvable *s;
- if (!count)
+ if (!s->arch || s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
return 0;
- p = pool_add_solvable_block(repo->pool, count);
- if (!repo->start || repo->start == repo->end)
- {
- repo->start = p;
- repo->end = p + count;
- }
- else
- {
- if (p < repo->start)
- repo->start = p;
- if (p + count > repo->end)
- repo->end = p + count;
+ if (s->repo && s->repo->disabled)
+ return 0;
+ if (pool->id2arch && (s->arch > pool->lastarch || !pool->id2arch[s->arch]))
+ return 0;
+ if (pool->considered)
+ {
+ Id id = s - pool->solvables;
+ if (!MAPTST(pool->considered, id))
+ return 0;
}
- repo->nsolvables += count;
- for (s = repo->pool->solvables + p; count--; s++)
- s->repo = repo;
- return p;
+ return 1;
}
-static inline void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids)
-{
- extern void pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids);
- Solvable *s;
- int i;
- if (start + count == repo->end)
- repo->end -= count;
- repo->nsolvables -= count;
- for (s = repo->pool->solvables + start, i = count; i--; s++)
- s->repo = 0;
- pool_free_solvable_block(repo->pool, start, count, reuseids);
-}
-
-#define FOR_REPO_SOLVABLES(r, p, s) \
- for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s = (r)->pool->solvables + p) \
- if (s->repo == (r))
-
-
/* search callback values */
-
#define SEARCH_NEXT_KEY 1
#define SEARCH_NEXT_SOLVABLE 2
#define SEARCH_STOP 3
+#define SEARCH_ENTERSUB -1
+
+/* standard flags used in the repo_add functions */
+#define REPO_REUSE_REPODATA (1 << 0)
+#define REPO_NO_INTERNALIZE (1 << 1)
+#define REPO_LOCALPOOL (1 << 2)
+#define REPO_USE_LOADING (1 << 3)
+#define REPO_EXTEND_SOLVABLES (1 << 4)
+#define REPO_USE_ROOTDIR (1 << 5)
-typedef struct _KeyValue {
- Id id;
- const char *str;
- int num;
- int num2;
- int eof;
-} KeyValue;
-
-/* search flags */
-#define SEARCH_STRINGMASK 15
-#define SEARCH_STRING 1
-#define SEARCH_SUBSTRING 2
-#define SEARCH_GLOB 3
-#define SEARCH_REGEX 4
-
-#define SEARCH_NOCASE (1<<8)
-#define SEARCH_NO_STORAGE_SOLVABLE (1<<9)
-#define SEARCH_EXTRA (1<<10)
-#define SEARCH_ALL_REPOS (1<<11)
-#define SEARCH_SKIP_KIND (1<<12)
-
-/* By default we don't match in attributes representing filelists
- because the construction of those strings is costly. Specify this
- flag if you want this. In that case kv->str will contain the full
- filename (if matched of course). */
-#define SEARCH_FILES (1<<13)
-
-/* Internal */
-#define __SEARCH_ONESOLVABLE (1 << 31)
-
-Repodata *repo_add_repodata(Repo *repo, int localpool);
+Repodata *repo_add_repodata(Repo *repo, int flags);
+Repodata *repo_id2repodata(Repo *repo, Id id);
+Repodata *repo_last_repodata(Repo *repo);
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);
/* returns the string value of the attribute, or NULL if not found */
-const char * repo_lookup_str(Solvable *s, Id key);
-/* returns the integer value of the attribute, or 0 if not found */
-unsigned int repo_lookup_num(Solvable *s, Id key);
-/* generic attribute lookup */
-int repo_lookup(Solvable *s, Id key, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *kv), void *cbdata);
-
-typedef struct _Dataiterator
-{
- Repodata *data;
- Id *keyp;
- unsigned char *nextkeydp;
- unsigned char *dp;
- Repokey *key;
- Repo *repo;
- Id *idp;
- const char *match;
- Id solvid;
- Id keyname;
- unsigned flags;
- unsigned state;
- KeyValue kv;
- regex_t regex;
- int regex_err;
- Id *subkeyp;
- int subnum;
- Id subschema;
-} Dataiterator;
-
-/* Use these like:
- Dataiterator di;
- dataiterator_init(&di, repo, 0, 0, "bla", SEARCH_SUBSTRING);
- while (dataiterator_step(&di))
- dosomething(di.solvid, di.key, di.kv); */
-void dataiterator_init(Dataiterator *di, Repo *repo, Id p, Id keyname,
- const char *match, int flags);
-int dataiterator_step(Dataiterator *di);
-int dataiterator_match(Dataiterator *di, int flags, const void *match);
-void dataiterator_skip_attribute(Dataiterator *di);
-void dataiterator_skip_solvable(Dataiterator *di);
-void dataiterator_skip_repo(Dataiterator *di);
-void dataiterator_jump_to_solvable(Dataiterator *di, Solvable *s);
-void dataiterator_jump_to_repo(Dataiterator *di, Repo *repo);
+Id repo_lookup_type(Repo *repo, Id entry, Id keyname);
+const char *repo_lookup_str(Repo *repo, Id entry, Id keyname);
+/* returns the integer value of the attribute, or notfound if not found */
+unsigned long long repo_lookup_num(Repo *repo, Id entry, Id keyname, unsigned long long notfound);
+Id repo_lookup_id(Repo *repo, Id entry, Id keyname);
+int repo_lookup_idarray(Repo *repo, Id entry, Id keyname, Queue *q);
+int repo_lookup_deparray(Repo *repo, Id entry, Id keyname, Queue *q, Id marker);
+int repo_lookup_void(Repo *repo, Id entry, Id keyname);
+const char *repo_lookup_checksum(Repo *repo, Id entry, Id keyname, Id *typep);
+const unsigned char *repo_lookup_bin_checksum(Repo *repo, Id entry, Id keyname, Id *typep);
void repo_set_id(Repo *repo, Id p, Id keyname, Id id);
-void repo_set_num(Repo *repo, Id p, Id keyname, Id num);
+void repo_set_num(Repo *repo, Id p, Id keyname, unsigned long long num);
void repo_set_str(Repo *repo, Id p, Id keyname, const char *str);
void repo_set_poolstr(Repo *repo, Id p, Id keyname, const char *str);
+void repo_add_poolstr_array(Repo *repo, Id p, Id keyname, const char *str);
+void repo_add_idarray(Repo *repo, Id p, Id keyname, Id id);
+void repo_add_deparray(Repo *repo, Id p, Id keyname, Id dep, Id marker);
+void repo_set_idarray(Repo *repo, Id p, Id keyname, Queue *q);
+void repo_set_deparray(Repo *repo, Id p, Id keyname, Queue *q, Id marker);
+
void repo_internalize(Repo *repo);
void repo_disable_paging(Repo *repo);
-#endif /* SATSOLVER_REPO_H */
+/* iterator macros */
+#define FOR_REPO_SOLVABLES(r, p, s) \
+ for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s = (r)->pool->solvables + p) \
+ if (s->repo != (r)) \
+ continue; \
+ else
+
+#ifdef LIBSOLV_INTERNAL
+#define FOR_REPODATAS(repo, rdid, data) \
+ for (rdid = 1, data = repo->repodata + rdid; rdid < repo->nrepodata; rdid++, data++)
+#else
+#define FOR_REPODATAS(repo, rdid, data) \
+ for (rdid = 1; rdid < repo->nrepodata && (data = repo_id2repodata(repo, rdid)); rdid++)
+#endif
+
+#endif /* LIBSOLV_REPO_H */