- add key filtering to repo_write
[platform/upstream/libsolv.git] / src / repodata.h
1 /*
2  * Copyright (c) 2007, Novell Inc.
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 /*
9  * repodata.h
10  * 
11  */
12
13 #ifndef SATSOLVER_REPODATA_H
14 #define SATSOLVER_REPODATA_H
15
16 #include "pooltypes.h"
17 #include "pool.h"
18 #include "dirpool.h"
19
20 struct _Repo;
21 struct _Repokey;
22 struct _KeyValue;
23
24 typedef struct _Attrblobpage
25 {
26   /* mapped_at == -1  --> not loaded, otherwise offset into
27      store->blob_store.  The size of the mapping is BLOB_PAGESIZE
28      except for the last page.  */
29   unsigned int mapped_at;
30   long file_offset;
31   /* file_size == 0 means the page is not backed by some file storage.
32      Otherwise it is L*2+(compressed ? 1 : 0), with L being the data
33      length.  */
34   long file_size;
35 } Attrblobpage;
36
37 typedef struct _Repodata {
38   struct _Repo *repo;           /* back pointer to repo */
39
40   int state;                    /* available, stub or error */
41
42   void (*loadcallback)(struct _Repodata *);
43
44   int start;                    /* start of solvables this repodata is valid for */
45   int end;                      /* last solvable + 1 of this repodata */
46
47   FILE *fp;                     /* file pointer of solv file */
48   int error;                    /* corrupt solv file */
49
50   struct _Repokey *keys;        /* keys, first entry is always zero */
51   unsigned int nkeys;           /* length of keys array */
52
53   Id *schemata;                 /* schema -> offset into schemadata */
54   unsigned int nschemata;       /* number of schemata */
55
56   Id *schemadata;               /* schema storage */
57   unsigned int schemadatalen;   /* schema storage size */
58
59   unsigned char *entryschemau8; /* schema for entry */
60   Id *entryschema;              /* schema for entry */
61
62   Stringpool spool;             /* local string pool */
63   int localpool;                /* is local string pool used */
64
65   Dirpool dirpool;              /* local dir pool */
66
67   unsigned char *incoredata;    /* in-core data (flat_attrs) */
68   unsigned int incoredatalen;   /* data len (attr_next_free) */
69   unsigned int incoredatafree;  /* free data len */
70
71   Id *incoreoffset;             /* offset for all entries (ent2attr) */
72
73   Id *verticaloffset;           /* offset for all verticals, nkeys elements */
74   Id lastverticaloffset;        /* end of verticals */
75
76   unsigned char *blob_store;
77
78   Attrblobpage *pages;
79   unsigned int num_pages;
80
81   /* mapped[i] is zero if nothing is mapped at logical page I,
82      otherwise it contains the pagenumber plus one (of the mapped page).  */
83   unsigned int *mapped;
84   unsigned int nmapped, ncanmap;
85   unsigned int rr_counter;
86
87   unsigned char *vincore;       
88   unsigned int vincorelen;
89
90   Id **attrs;                   /* un-internalized attributes */
91   unsigned char *attrdata;      /* their string data space */
92   unsigned int attrdatalen;
93   Id *attriddata;               /* their id space */
94   unsigned int attriddatalen;
95
96 } Repodata;
97
98 #define REPODATA_AVAILABLE      0
99 #define REPODATA_STUB           1
100 #define REPODATA_ERROR          2
101 #define REPODATA_STORE          3
102
103 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);
104 const char *repodata_lookup_str(Repodata *data, Id entry, Id keyid);
105
106 void repodata_extend(Repodata *data, Id p);
107
108 void repodata_set_id(Repodata *data, Id entry, Id keyname, Id id);
109 void repodata_set_num(Repodata *data, Id entry, Id keyname, Id num);
110 void repodata_set_poolstr(Repodata *data, Id entry, Id keyname, const char *str);
111 void repodata_set_constant(Repodata *data, Id entry, Id keyname, Id constant);
112 void repodata_set_void(Repodata *data, Id entry, Id keyname);
113 void repodata_set_str(Repodata *data, Id entry, Id keyname, const char *str);
114 void repodata_add_dirnumnum(Repodata *data, Id entry, Id keyname, Id dir, Id num, Id num2);
115
116 void repodata_internalize(Repodata *data);
117
118 Id repodata_str2dir(Repodata *data, const char *dir, int create);
119
120 unsigned int repodata_compress_page(unsigned char *, unsigned int, unsigned char *, unsigned int);
121 void repodata_read_or_setup_pages(Repodata *data, unsigned int pagesz, unsigned int blobsz);
122
123 #endif /* SATSOLVER_REPODATA_H */