00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef SATSOLVER_REPODATA_H
00014 #define SATSOLVER_REPODATA_H
00015
00016 #include <stdio.h>
00017
00018 #include "pooltypes.h"
00019 #include "pool.h"
00020 #include "dirpool.h"
00021 #include "repopage.h"
00022
00023 #define SIZEOF_MD5 16
00024 #define SIZEOF_SHA1 20
00025 #define SIZEOF_SHA256 32
00026
00027 struct _Repo;
00028 struct _KeyValue;
00029
00030 typedef struct _Repokey {
00031 Id name;
00032 Id type;
00033 unsigned int size;
00034 unsigned int storage;
00035 } Repokey;
00036
00037 #define KEY_STORAGE_DROPPED 0
00038 #define KEY_STORAGE_SOLVABLE 1
00039 #define KEY_STORAGE_INCORE 2
00040 #define KEY_STORAGE_VERTICAL_OFFSET 3
00041
00042
00043 typedef struct _Repodata {
00044 struct _Repo *repo;
00045
00046 #define REPODATA_AVAILABLE 0
00047 #define REPODATA_STUB 1
00048 #define REPODATA_ERROR 2
00049 #define REPODATA_STORE 3
00050 #define REPODATA_LOADING 4
00051
00052 int state;
00053
00054 void (*loadcallback)(struct _Repodata *);
00055
00056 int start;
00057 int end;
00058
00059 FILE *fp;
00060 int error;
00061
00062 Repokey *keys;
00063 unsigned int nkeys;
00064 unsigned char keybits[32];
00065
00066 Id *schemata;
00067 unsigned int nschemata;
00068 Id *schemadata;
00069 unsigned int schemadatalen;
00070 Id *schematahash;
00071
00072 Stringpool spool;
00073 int localpool;
00074
00075 Dirpool dirpool;
00076
00077 unsigned char *incoredata;
00078 unsigned int incoredatalen;
00079 unsigned int incoredatafree;
00080
00081 Id mainschema;
00082 Id *mainschemaoffsets;
00083
00084 Id *incoreoffset;
00085
00086 Id *verticaloffset;
00087 Id lastverticaloffset;
00088
00089 Repopagestore store;
00090
00091 unsigned char *vincore;
00092 unsigned int vincorelen;
00093
00094 Id **attrs;
00095 Id **xattrs;
00096 int nxattrs;
00097
00098 unsigned char *attrdata;
00099 unsigned int attrdatalen;
00100 Id *attriddata;
00101 unsigned int attriddatalen;
00102
00103
00104 Id lasthandle;
00105 Id lastkey;
00106 Id lastdatalen;
00107
00108 } Repodata;
00109
00110 #define SOLVID_META -1
00111 #define SOLVID_POS -2
00112 #define SOLVID_SUBSCHEMA -3
00113
00114
00115
00116
00117
00118 void repodata_initdata(Repodata *data, struct _Repo *repo, int localpool);
00119 void repodata_freedata(Repodata *data);
00120
00121 Repodata *repodata_create(struct _Repo *repo, int localpool);
00122 void repodata_free(Repodata *data);
00123 void repodata_empty(Repodata *data, int localpool);
00124
00125
00126
00127
00128
00129 Id repodata_key2id(Repodata *data, Repokey *key, int create);
00130
00131 static inline Repokey *
00132 repodata_id2key(Repodata *data, Id keyid)
00133 {
00134 return data->keys + keyid;
00135 }
00136
00137
00138
00139
00140 Id repodata_schema2id(Repodata *data, Id *schema, int create);
00141 void repodata_free_schemahash(Repodata *data);
00142
00143 static inline Id *
00144 repodata_id2schema(Repodata *data, Id schemaid)
00145 {
00146 return data->schemadata + data->schemata[schemaid];
00147 }
00148
00149
00150
00151
00152
00153
00154
00155 static inline int
00156 repodata_precheck_keyname(Repodata *data, Id keyname)
00157 {
00158 unsigned char x = data->keybits[(keyname >> 3) & (sizeof(data->keybits) - 1)];
00159 return x && (x & (1 << (keyname & 7))) ? 1 : 0;
00160 }
00161
00162
00163 static inline int
00164 repodata_has_keyname(Repodata *data, Id keyname)
00165 {
00166 int i;
00167 if (!repodata_precheck_keyname(data, keyname))
00168 return 0;
00169 for (i = 1; i < data->nkeys; i++)
00170 if (data->keys[i].name == keyname)
00171 return 1;
00172 return 0;
00173 }
00174
00175
00176
00177 void repodata_search(Repodata *data, Id solvid, Id keyname, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, struct _KeyValue *kv), void *cbdata);
00178
00179
00180
00181 int repodata_stringify(Pool *pool, Repodata *data, Repokey *key, struct _KeyValue *kv, int flags);
00182
00183 int repodata_filelistfilter_matches(Repodata *data, const char *str);
00184
00185
00186
00187 Id repodata_lookup_type(Repodata *data, Id solvid, Id keyname);
00188 Id repodata_lookup_id(Repodata *data, Id solvid, Id keyname);
00189 const char *repodata_lookup_str(Repodata *data, Id solvid, Id keyname);
00190 int repodata_lookup_num(Repodata *data, Id solvid, Id keyname, unsigned int *value);
00191 int repodata_lookup_void(Repodata *data, Id solvid, Id keyname);
00192 const unsigned char *repodata_lookup_bin_checksum(Repodata *data, Id solvid, Id keyname, Id *typep);
00193 int repodata_lookup_idarray(Repodata *data, Id solvid, Id keyname, Queue *q);
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 void repodata_extend(Repodata *data, Id p);
00205 void repodata_extend_block(Repodata *data, Id p, int num);
00206 void repodata_shrink(Repodata *data, int end);
00207
00208
00209
00210 void repodata_internalize(Repodata *data);
00211
00212
00213
00214 Id repodata_new_handle(Repodata *data);
00215
00216
00217 void repodata_set_void(Repodata *data, Id solvid, Id keyname);
00218 void repodata_set_num(Repodata *data, Id solvid, Id keyname, unsigned int num);
00219 void repodata_set_id(Repodata *data, Id solvid, Id keyname, Id id);
00220 void repodata_set_str(Repodata *data, Id solvid, Id keyname, const char *str);
00221 void repodata_set_binary(Repodata *data, Id solvid, Id keyname, void *buf, int len);
00222
00223 void repodata_set_poolstr(Repodata *data, Id solvid, Id keyname, const char *str);
00224
00225
00226 void repodata_set_constant(Repodata *data, Id solvid, Id keyname, unsigned int constant);
00227
00228
00229 void repodata_set_constantid(Repodata *data, Id solvid, Id keyname, Id id);
00230
00231
00232 void repodata_set_bin_checksum(Repodata *data, Id solvid, Id keyname, Id type,
00233 const unsigned char *buf);
00234 void repodata_set_checksum(Repodata *data, Id solvid, Id keyname, Id type,
00235 const char *str);
00236 void repodata_set_idarray(Repodata *data, Id solvid, Id keyname, Queue *q);
00237
00238
00239
00240 void repodata_add_dirnumnum(Repodata *data, Id solvid, Id keyname, Id dir, Id num, Id num2);
00241 void repodata_add_dirstr(Repodata *data, Id solvid, Id keyname, Id dir, const char *str);
00242
00243
00244
00245 void repodata_add_idarray(Repodata *data, Id solvid, Id keyname, Id id);
00246 void repodata_add_poolstr_array(Repodata *data, Id solvid, Id keyname, const char *str);
00247 void repodata_add_fixarray(Repodata *data, Id solvid, Id keyname, Id ghandle);
00248 void repodata_add_flexarray(Repodata *data, Id solvid, Id keyname, Id ghandle);
00249
00250 void repodata_delete(Repodata *data, Id solvid, Id keyname);
00251 void repodata_delete_uninternalized(Repodata *data, Id solvid, Id keyname);
00252
00253
00254
00255
00256
00257 void repodata_merge_attrs(Repodata *data, Id dest, Id src);
00258 void repodata_merge_some_attrs(Repodata *data, Id dest, Id src, Map *keyidmap, int overwrite);
00259
00260 void repodata_create_stubs(Repodata *data);
00261 void repodata_join(Repodata *data, Id joinkey);
00262
00263
00264
00265
00266 void repodata_disable_paging(Repodata *data);
00267
00268
00269 Id repodata_globalize_id(Repodata *data, Id id, int create);
00270 Id repodata_localize_id(Repodata *data, Id id, int create);
00271 Id repodata_str2dir(Repodata *data, const char *dir, int create);
00272 const char *repodata_dir2str(Repodata *data, Id did, const char *suf);
00273 const char *repodata_chk2str(Repodata *data, Id type, const unsigned char *buf);
00274 void repodata_set_location(Repodata *data, Id solvid, int medianr, const char *dir, const char *file);
00275
00276 #endif