#ifndef LIBSOLV_REPODATA_H
#define LIBSOLV_REPODATA_H
#include <stdio.h>
#include "pooltypes.h"
#include "pool.h"
#include "dirpool.h"
#ifdef LIBSOLV_INTERNAL
#include "repopage.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define SIZEOF_MD5 16
#define SIZEOF_SHA1 20
#define SIZEOF_SHA224 28
#define SIZEOF_SHA256 32
#define SIZEOF_SHA384 48
#define SIZEOF_SHA512 64
struct s_KeyValue;
typedef struct s_Repokey {
Id name;
Id type;
unsigned int size;
unsigned int storage;
} Repokey;
#define KEY_STORAGE_DROPPED 0
#define KEY_STORAGE_SOLVABLE 1
#define KEY_STORAGE_INCORE 2
#define KEY_STORAGE_VERTICAL_OFFSET 3
#define KEY_STORAGE_IDARRAYBLOCK 4
#ifdef LIBSOLV_INTERNAL
struct dircache;
#endif
#define REPODATA_AVAILABLE 0
#define REPODATA_STUB 1
#define REPODATA_ERROR 2
#define REPODATA_STORE 3
#define REPODATA_LOADING 4
#define REPODATA_FILELIST_FILTERED 1
#define REPODATA_FILELIST_EXTENSION 2
struct s_Repodata {
Id repodataid;
Repo *repo;
int state;
void (*loadcallback)(Repodata *);
int start;
int end;
Repokey *keys;
int nkeys;
unsigned char keybits[32];
Id *schemata;
int nschemata;
Id *schemadata;
Stringpool spool;
int localpool;
Dirpool dirpool;
#ifdef LIBSOLV_INTERNAL
FILE *fp;
int error;
int filelisttype;
Id *filelistfilter;
char *filelistfilterdata;
unsigned int schemadatalen;
Id *schematahash;
unsigned char *incoredata;
unsigned int incoredatalen;
unsigned int incoredatafree;
Id mainschema;
Id *mainschemaoffsets;
Id *incoreoffset;
Id *verticaloffset;
Id lastverticaloffset;
Repopagestore store;
Id storestate;
unsigned char *vincore;
unsigned int vincorelen;
Id **attrs;
Id **xattrs;
int nxattrs;
unsigned char *attrdata;
unsigned int attrdatalen;
Id *attriddata;
unsigned int attriddatalen;
unsigned long long *attrnum64data;
unsigned int attrnum64datalen;
Id lasthandle;
Id lastkey;
Id lastdatalen;
struct dircache *dircache;
#endif
};
#define SOLVID_META -1
#define SOLVID_POS -2
void repodata_initdata(Repodata *data, Repo *repo, int localpool);
void repodata_freedata(Repodata *data);
void repodata_free(Repodata *data);
void repodata_empty(Repodata *data, int localpool);
void repodata_load(Repodata *data);
Id repodata_key2id(Repodata *data, Repokey *key, int create);
static inline Repokey *
repodata_id2key(Repodata *data, Id keyid)
{
return data->keys + keyid;
}
Id repodata_schema2id(Repodata *data, Id *schema, int create);
void repodata_free_schemahash(Repodata *data);
static inline Id *
repodata_id2schema(Repodata *data, Id schemaid)
{
return data->schemadata + data->schemata[schemaid];
}
static inline int
repodata_precheck_keyname(Repodata *data, Id keyname)
{
unsigned char x = data->keybits[(keyname >> 3) & (sizeof(data->keybits) - 1)];
return x && (x & (1 << (keyname & 7))) ? 1 : 0;
}
static inline int
repodata_has_keyname(Repodata *data, Id keyname)
{
int i;
if (!repodata_precheck_keyname(data, keyname))
return 0;
for (i = 1; i < data->nkeys; i++)
if (data->keys[i].name == keyname)
return 1;
return 0;
}
void repodata_search(Repodata *data, Id solvid, Id keyname, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, struct s_KeyValue *kv), void *cbdata);
void repodata_search_keyskip(Repodata *data, Id solvid, Id keyname, int flags, Id *keyskip, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, struct s_KeyValue *kv), void *cbdata);
void repodata_search_arrayelement(Repodata *data, Id solvid, Id keyname, int flags, struct s_KeyValue *kv, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, struct s_KeyValue *kv), void *cbdata);
const char *repodata_stringify(Pool *pool, Repodata *data, Repokey *key, struct s_KeyValue *kv, int flags);
void repodata_set_filelisttype(Repodata *data, int filelisttype);
int repodata_filelistfilter_matches(Repodata *data, const char *str);
void repodata_free_filelistfilter(Repodata *data);
Id repodata_lookup_type(Repodata *data, Id solvid, Id keyname);
Id repodata_lookup_id(Repodata *data, Id solvid, Id keyname);
const char *repodata_lookup_str(Repodata *data, Id solvid, Id keyname);
unsigned long long repodata_lookup_num(Repodata *data, Id solvid, Id keyname, unsigned long long notfound);
int repodata_lookup_void(Repodata *data, Id solvid, Id keyname);
const unsigned char *repodata_lookup_bin_checksum(Repodata *data, Id solvid, Id keyname, Id *typep);
int repodata_lookup_idarray(Repodata *data, Id solvid, Id keyname, Queue *q);
const void *repodata_lookup_binary(Repodata *data, Id solvid, Id keyname, int *lenp);
unsigned int repodata_lookup_count(Repodata *data, Id solvid, Id keyname);
const unsigned char *repodata_lookup_packed_dirstrarray(Repodata *data, Id solvid, Id keyname);
Id *repodata_fill_keyskip(Repodata *data, Id solvid, Id *keyskip);
void repodata_extend(Repodata *data, Id p);
void repodata_extend_block(Repodata *data, Id p, int num);
void repodata_shrink(Repodata *data, int end);
void repodata_internalize(Repodata *data);
Id repodata_new_handle(Repodata *data);
void repodata_set_void(Repodata *data, Id solvid, Id keyname);
void repodata_set_num(Repodata *data, Id solvid, Id keyname, unsigned long long num);
void repodata_set_id(Repodata *data, Id solvid, Id keyname, Id id);
void repodata_set_str(Repodata *data, Id solvid, Id keyname, const char *str);
void repodata_set_binary(Repodata *data, Id solvid, Id keyname, void *buf, int len);
void repodata_set_poolstr(Repodata *data, Id solvid, Id keyname, const char *str);
void repodata_set_constant(Repodata *data, Id solvid, Id keyname, unsigned int constant);
void repodata_set_constantid(Repodata *data, Id solvid, Id keyname, Id id);
void repodata_set_bin_checksum(Repodata *data, Id solvid, Id keyname, Id type,
const unsigned char *buf);
void repodata_set_checksum(Repodata *data, Id solvid, Id keyname, Id type,
const char *str);
void repodata_set_idarray(Repodata *data, Id solvid, Id keyname, Queue *q);
void repodata_add_dirnumnum(Repodata *data, Id solvid, Id keyname, Id dir, Id num, Id num2);
void repodata_add_dirstr(Repodata *data, Id solvid, Id keyname, Id dir, const char *str);
void repodata_free_dircache(Repodata *data);
void repodata_add_idarray(Repodata *data, Id solvid, Id keyname, Id id);
void repodata_add_poolstr_array(Repodata *data, Id solvid, Id keyname, const char *str);
void repodata_add_fixarray(Repodata *data, Id solvid, Id keyname, Id ghandle);
void repodata_add_flexarray(Repodata *data, Id solvid, Id keyname, Id ghandle);
void repodata_set_kv(Repodata *data, Id solvid, Id keyname, Id keytype, struct s_KeyValue *kv);
void repodata_unset(Repodata *data, Id solvid, Id keyname);
void repodata_unset_uninternalized(Repodata *data, Id solvid, Id keyname);
void repodata_merge_attrs(Repodata *data, Id dest, Id src);
void repodata_merge_some_attrs(Repodata *data, Id dest, Id src, Map *keyidmap, int overwrite);
void repodata_swap_attrs(Repodata *data, Id dest, Id src);
Repodata *repodata_create_stubs(Repodata *data);
void repodata_disable_paging(Repodata *data);
Id repodata_globalize_id(Repodata *data, Id id, int create);
Id repodata_localize_id(Repodata *data, Id id, int create);
Id repodata_translate_id(Repodata *data, Repodata *fromdata, Id id, int create);
Id repodata_translate_dir_slow(Repodata *data, Repodata *fromdata, Id dir, int create, Id *cache);
Id repodata_str2dir(Repodata *data, const char *dir, int create);
const char *repodata_dir2str(Repodata *data, Id did, const char *suf);
const char *repodata_chk2str(Repodata *data, Id type, const unsigned char *buf);
void repodata_set_location(Repodata *data, Id solvid, int medianr, const char *dir, const char *file);
void repodata_set_deltalocation(Repodata *data, Id handle, int medianr, const char *dir, const char *file);
void repodata_set_sourcepkg(Repodata *data, Id solvid, const char *sourcepkg);
Repokey *repodata_lookup_kv_uninternalized(Repodata *data, Id solvid, Id keyname, struct s_KeyValue *kv);
void repodata_search_uninternalized(Repodata *data, Id solvid, Id keyname, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, struct s_KeyValue *kv), void *cbdata);
unsigned int repodata_memused(Repodata *data);
static inline Id
repodata_translate_dir(Repodata *data, Repodata *fromdata, Id dir, int create, Id *cache)
{
if (cache && dir && cache[(dir & 255) * 2] == dir)
return cache[(dir & 255) * 2 + 1];
return repodata_translate_dir_slow(data, fromdata, dir, create, cache);
}
static inline Id *
repodata_create_dirtranscache(Repodata *data)
{
return (Id *)solv_calloc(256, sizeof(Id) * 2);
}
static inline Id *
repodata_free_dirtranscache(Id *cache)
{
return (Id *)solv_free(cache);
}
#ifdef __cplusplus
}
#endif
#endif