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_REPODATA_H
14 #define SATSOLVER_REPODATA_H
18 #include "pooltypes.h"
23 #define SIZEOF_SHA1 20
24 #define SIZEOF_SHA256 32
30 typedef struct _Attrblobpage
32 /* mapped_at == -1 --> not loaded, otherwise offset into
33 store->blob_store. The size of the mapping is BLOB_PAGESIZE
34 except for the last page. */
35 unsigned int mapped_at;
37 /* file_size == 0 means the page is not backed by some file storage.
38 Otherwise it is L*2+(compressed ? 1 : 0), with L being the data
43 typedef struct _Repodata {
44 struct _Repo *repo; /* back pointer to repo */
46 #define REPODATA_AVAILABLE 0
47 #define REPODATA_STUB 1
48 #define REPODATA_ERROR 2
49 #define REPODATA_STORE 3
50 int state; /* available, stub or error */
52 void (*loadcallback)(struct _Repodata *);
53 char *location; /* E.g. filename or the like */
54 char *checksum; /* Checksum of the file */
55 unsigned nchecksum; /* Length of the checksum */
56 unsigned checksumtype; /* Type of checksum */
58 int start; /* start of solvables this repodata is valid for */
59 int end; /* last solvable + 1 of this repodata */
61 FILE *fp; /* file pointer of solv file */
62 int error; /* corrupt solv file */
65 struct _Repokey *keys; /* keys, first entry is always zero */
66 unsigned int nkeys; /* length of keys array */
68 Id *schemata; /* schema -> offset into schemadata */
69 unsigned int nschemata; /* number of schemata */
71 Id *schemadata; /* schema storage */
72 unsigned int schemadatalen; /* schema storage size */
74 Stringpool spool; /* local string pool */
75 int localpool; /* is local string pool used */
77 Dirpool dirpool; /* local dir pool */
79 unsigned char *incoredata; /* in-core data (flat_attrs) */
80 unsigned int incoredatalen; /* data len (attr_next_free) */
81 unsigned int incoredatafree; /* free data len */
83 Id *incoreoffset; /* offset for all entries (ent2attr) */
85 Id *verticaloffset; /* offset for all verticals, nkeys elements */
86 Id lastverticaloffset; /* end of verticals */
88 int pagefd; /* file descriptor of page file */
89 unsigned char *blob_store;
91 unsigned int num_pages;
93 /* mapped[i] is zero if nothing is mapped at logical page I,
94 otherwise it contains the pagenumber plus one (of the mapped page). */
96 unsigned int nmapped, ncanmap;
97 unsigned int rr_counter;
99 unsigned char *vincore;
100 unsigned int vincorelen;
102 Id **attrs; /* un-internalized attributes */
103 unsigned char *attrdata; /* their string data space */
104 unsigned int attrdatalen;
105 Id *attriddata; /* their id space */
106 unsigned int attriddatalen;
108 Id *addedfileprovides;
111 /* Search key <keyname> (all keys, if keyname == 0) for Id <entry>
112 * <entry> is _relative_ Id for <data>
113 * Call <callback> for each match
115 void repodata_search(Repodata *data, Id entry, Id keyname, int (*callback)(void *cbdata, Solvable *s, Repodata *data, struct _Repokey *key, struct _KeyValue *kv), void *cbdata);
118 * lookup string type attribute
120 const char *repodata_lookup_str(Repodata *data, Id entry, Id keyid);
123 * lookup integer type attribute
125 int repodata_lookup_num(Repodata *data, Id entry, Id keyid, unsigned *value);
126 int repodata_lookup_void(Repodata *data, Id entry, Id keyid);
128 void repodata_init(Repodata *data, struct _Repo *repo, int localpool);
129 void repodata_extend(Repodata *data, Id p);
130 void repodata_extend_block(Repodata *data, Id p, int num);
131 void repodata_free(Repodata *data);
133 void repodata_set_id(Repodata *data, Id entry, Id keyname, Id id);
134 void repodata_set_num(Repodata *data, Id entry, Id keyname, Id num);
135 void repodata_set_poolstr(Repodata *data, Id entry, Id keyname, const char *str);
136 void repodata_set_constant(Repodata *data, Id entry, Id keyname, Id constant);
137 void repodata_set_constantid(Repodata *data, Id entry, Id keyname, Id id);
138 void repodata_set_void(Repodata *data, Id entry, Id keyname);
139 void repodata_set_str(Repodata *data, Id entry, Id keyname, const char *str);
140 void repodata_set_bin_checksum(Repodata *data, Id entry, Id keyname, Id type,
141 const unsigned char *buf);
142 void repodata_set_checksum(Repodata *data, Id entry, Id keyname, Id type,
144 void repodata_add_dirnumnum(Repodata *data, Id entry, Id keyname, Id dir, Id num, Id num2);
145 void repodata_add_dirstr(Repodata *data, Id entry, Id keyname, Id dir, const char *str);
146 void repodata_add_idarray(Repodata *data, Id entry, Id keyname, Id id);
147 void repodata_add_poolstr_array(Repodata *data, Id entry, Id keyname,
149 void repodata_merge_attrs (Repodata *data, Id dest, Id src);
151 void repodata_internalize(Repodata *data);
152 void repodata_disable_paging(Repodata *data);
154 Id repodata_str2dir(Repodata *data, const char *dir, int create);
155 const char *repodata_dir2str(Repodata *data, Id did, const char *suf);
156 const char *repodata_chk2str(Repodata *data, Id type, const char *buf);
158 unsigned int repodata_compress_page(unsigned char *, unsigned int, unsigned char *, unsigned int);
159 void repodata_read_or_setup_pages(Repodata *data, unsigned int pagesz, unsigned int blobsz);
161 #endif /* SATSOLVER_REPODATA_H */