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"
26 typedef struct _Attrblobpage
28 /* mapped_at == -1 --> not loaded, otherwise offset into
29 store->blob_store. The size of the mapping is BLOB_PAGESIZE
30 except for the last page. */
31 unsigned int mapped_at;
33 /* file_size == 0 means the page is not backed by some file storage.
34 Otherwise it is L*2+(compressed ? 1 : 0), with L being the data
39 typedef struct _Repodata {
40 struct _Repo *repo; /* back pointer to repo */
42 #define REPODATA_AVAILABLE 0
43 #define REPODATA_STUB 1
44 #define REPODATA_ERROR 2
45 #define REPODATA_STORE 3
46 int state; /* available, stub or error */
48 void (*loadcallback)(struct _Repodata *);
49 char *location; /* E.g. filename or the like */
50 char *checksum; /* Checksum of the file */
51 unsigned nchecksum; /* Length of the checksum */
52 unsigned checksumtype; /* Type of checksum */
54 int start; /* start of solvables this repodata is valid for */
55 int end; /* last solvable + 1 of this repodata */
57 FILE *fp; /* file pointer of solv file */
58 int error; /* corrupt solv file */
60 struct _Repokey *keys; /* keys, first entry is always zero */
61 unsigned int nkeys; /* length of keys array */
63 Id *schemata; /* schema -> offset into schemadata */
64 unsigned int nschemata; /* number of schemata */
66 Id *schemadata; /* schema storage */
67 unsigned int schemadatalen; /* schema storage size */
69 Stringpool spool; /* local string pool */
70 int localpool; /* is local string pool used */
72 Dirpool dirpool; /* local dir pool */
74 unsigned char *incoredata; /* in-core data (flat_attrs) */
75 unsigned int incoredatalen; /* data len (attr_next_free) */
76 unsigned int incoredatafree; /* free data len */
78 Id *incoreoffset; /* offset for all entries (ent2attr) */
80 Id *verticaloffset; /* offset for all verticals, nkeys elements */
81 Id lastverticaloffset; /* end of verticals */
83 unsigned char *blob_store;
86 unsigned int num_pages;
88 /* mapped[i] is zero if nothing is mapped at logical page I,
89 otherwise it contains the pagenumber plus one (of the mapped page). */
91 unsigned int nmapped, ncanmap;
92 unsigned int rr_counter;
94 unsigned char *vincore;
95 unsigned int vincorelen;
97 Id **attrs; /* un-internalized attributes */
98 unsigned char *attrdata; /* their string data space */
99 unsigned int attrdatalen;
100 Id *attriddata; /* their id space */
101 unsigned int attriddatalen;
105 /* Search key <keyname> (all keys, if keyname == 0) for Id <entry>
106 * <entry> is _relative_ Id for <data>
107 * Call <callback> for each match
109 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);
112 * lookup string type attribute
114 const char *repodata_lookup_str(Repodata *data, Id entry, Id keyid);
117 * lookup integer type attribute
119 int repodata_lookup_num(Repodata *data, Id entry, Id keyid, unsigned *value);
121 void repodata_extend(Repodata *data, Id p);
122 void repodata_free(Repodata *data);
124 void repodata_set_id(Repodata *data, Id entry, Id keyname, Id id);
125 void repodata_set_num(Repodata *data, Id entry, Id keyname, Id num);
126 void repodata_set_poolstr(Repodata *data, Id entry, Id keyname, const char *str);
127 void repodata_set_constant(Repodata *data, Id entry, Id keyname, Id constant);
128 void repodata_set_void(Repodata *data, Id entry, Id keyname);
129 void repodata_set_str(Repodata *data, Id entry, Id keyname, const char *str);
130 void repodata_add_dirnumnum(Repodata *data, Id entry, Id keyname, Id dir, Id num, Id num2);
131 void repodata_add_dirstr(Repodata *data, Id entry, Id keyname, Id dir, const char *str);
132 void repodata_merge_attrs (Repodata *data, Id dest, Id src);
134 void repodata_internalize(Repodata *data);
136 Id repodata_str2dir(Repodata *data, const char *dir, int create);
138 unsigned int repodata_compress_page(unsigned char *, unsigned int, unsigned char *, unsigned int);
139 void repodata_read_or_setup_pages(Repodata *data, unsigned int pagesz, unsigned int blobsz);
141 #endif /* SATSOLVER_REPODATA_H */