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
00124
00125
00126
00127
00128 Id repodata_key2id(Repodata *data, Repokey *key, int create);
00129 static inline Repokey *
00130 repodata_id2key(Repodata *data, Id keyid)
00131 {
00132 return data->keys + keyid;
00133 }
00134
00135
00136
00137
00138 Id repodata_schema2id(Repodata *data, Id *schema, int create);
00139 static inline Id *
00140 repodata_id2schema(Repodata *data, Id schemaid)
00141 {
00142 return data->schemadata + data->schemata[schemaid];
00143 }
00144
00145
00146
00147
00148
00149
00150
00151 static inline int
00152 repodata_precheck_keyname(Repodata *data, Id keyname)
00153 {
00154 unsigned char x = data->keybits[(keyname >> 3) & (sizeof(data->keybits) - 1)];
00155 return x && (x & (1 << (keyname & 7))) ? 1 : 0;
00156 }
00157
00158
00159 static inline int
00160 repodata_has_keyname(Repodata *data, Id keyname)
00161 {
00162 int i;
00163 if (!repodata_precheck_keyname(data, keyname))
00164 return 0;
00165 for (i = 1; i < data->nkeys; i++)
00166 if (data->keys[i].name == keyname)
00167 return 1;
00168 return 0;
00169 }
00170
00171
00172
00173 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);
00174
00175
00176
00177 int repodata_stringify(Pool *pool, Repodata *data, Repokey *key, struct _KeyValue *kv, int flags);
00178
00179 int repodata_filelistfilter_matches(Repodata *data, const char *str);
00180
00181
00182
00183 Id repodata_lookup_id(Repodata *data, Id solvid, Id keyname);
00184 const char *repodata_lookup_str(Repodata *data, Id solvid, Id keyname);
00185 int repodata_lookup_num(Repodata *data, Id solvid, Id keyname, unsigned int *value);
00186 int repodata_lookup_void(Repodata *data, Id solvid, Id keyname);
00187 const unsigned char *repodata_lookup_bin_checksum(Repodata *data, Id solvid, Id keyname, Id *typep);
00188 int repodata_lookup_idarray(Repodata *data, Id solvid, Id keyname, Queue *q);
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 void repodata_extend(Repodata *data, Id p);
00200 void repodata_extend_block(Repodata *data, Id p, int num);
00201 void repodata_shrink(Repodata *data, int end);
00202
00203
00204
00205 void repodata_internalize(Repodata *data);
00206
00207
00208
00209 Id repodata_new_handle(Repodata *data);
00210
00211
00212 void repodata_set_void(Repodata *data, Id solvid, Id keyname);
00213 void repodata_set_num(Repodata *data, Id solvid, Id keyname, unsigned int num);
00214 void repodata_set_id(Repodata *data, Id solvid, Id keyname, Id id);
00215 void repodata_set_str(Repodata *data, Id solvid, Id keyname, const char *str);
00216 void repodata_set_binary(Repodata *data, Id solvid, Id keyname, void *buf, int len);
00217
00218 void repodata_set_poolstr(Repodata *data, Id solvid, Id keyname, const char *str);
00219
00220
00221 void repodata_set_constant(Repodata *data, Id solvid, Id keyname, unsigned int constant);
00222
00223
00224 void repodata_set_constantid(Repodata *data, Id solvid, Id keyname, Id id);
00225
00226
00227 void repodata_set_bin_checksum(Repodata *data, Id solvid, Id keyname, Id type,
00228 const unsigned char *buf);
00229 void repodata_set_checksum(Repodata *data, Id solvid, Id keyname, Id type,
00230 const char *str);
00231
00232
00233 void repodata_add_dirnumnum(Repodata *data, Id solvid, Id keyname, Id dir, Id num, Id num2);
00234 void repodata_add_dirstr(Repodata *data, Id solvid, Id keyname, Id dir, const char *str);
00235
00236
00237
00238 void repodata_add_idarray(Repodata *data, Id solvid, Id keyname, Id id);
00239 void repodata_add_poolstr_array(Repodata *data, Id solvid, Id keyname, const char *str);
00240 void repodata_add_fixarray(Repodata *data, Id solvid, Id keyname, Id ghandle);
00241 void repodata_add_flexarray(Repodata *data, Id solvid, Id keyname, Id ghandle);
00242
00243 void repodata_delete_uninternalized(Repodata *data, Id solvid, Id keyname);
00244
00245
00246
00247
00248
00249 void repodata_merge_attrs(Repodata *data, Id dest, Id src);
00250 void repodata_merge_some_attrs(Repodata *data, Id dest, Id src, Map *keyidmap, int overwrite);
00251
00252 void repodata_create_stubs(Repodata *data);
00253 void repodata_join(Repodata *data, Id joinkey);
00254
00255
00256
00257
00258 void repodata_disable_paging(Repodata *data);
00259
00260
00261 Id repodata_globalize_id(Repodata *data, Id id, int create);
00262 Id repodata_str2dir(Repodata *data, const char *dir, int create);
00263 const char *repodata_dir2str(Repodata *data, Id did, const char *suf);
00264 const char *repodata_chk2str(Repodata *data, Id type, const unsigned char *buf);
00265 void repodata_set_location(Repodata *data, Id solvid, int medianr, const char *dir, const char *file);
00266
00267 #endif