expose repo_lookup_str and add lookup_num (nonworking)
[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 <stdio.h> 
17
18 #include "pooltypes.h"
19 #include "pool.h"
20 #include "dirpool.h"
21
22 struct _Repo;
23 struct _Repokey;
24 struct _KeyValue;
25
26 typedef struct _Attrblobpage
27 {
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;
32   long file_offset;
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
35      length.  */
36   long file_size;
37 } Attrblobpage;
38
39 typedef struct _Repodata {
40   struct _Repo *repo;           /* back pointer to repo */
41
42   int state;                    /* available, stub or error */
43
44   void (*loadcallback)(struct _Repodata *);
45
46   int start;                    /* start of solvables this repodata is valid for */
47   int end;                      /* last solvable + 1 of this repodata */
48
49   FILE *fp;                     /* file pointer of solv file */
50   int error;                    /* corrupt solv file */
51
52   struct _Repokey *keys;        /* keys, first entry is always zero */
53   unsigned int nkeys;           /* length of keys array */
54
55   Id *schemata;                 /* schema -> offset into schemadata */
56   unsigned int nschemata;       /* number of schemata */
57
58   Id *schemadata;               /* schema storage */
59   unsigned int schemadatalen;   /* schema storage size */
60
61   Stringpool spool;             /* local string pool */
62   int localpool;                /* is local string pool used */
63
64   Dirpool dirpool;              /* local dir pool */
65
66   unsigned char *incoredata;    /* in-core data (flat_attrs) */
67   unsigned int incoredatalen;   /* data len (attr_next_free) */
68   unsigned int incoredatafree;  /* free data len */
69
70   Id *incoreoffset;             /* offset for all entries (ent2attr) */
71
72   Id *verticaloffset;           /* offset for all verticals, nkeys elements */
73   Id lastverticaloffset;        /* end of verticals */
74
75   unsigned char *blob_store;
76
77   Attrblobpage *pages;
78   unsigned int num_pages;
79
80   /* mapped[i] is zero if nothing is mapped at logical page I,
81      otherwise it contains the pagenumber plus one (of the mapped page).  */
82   unsigned int *mapped;
83   unsigned int nmapped, ncanmap;
84   unsigned int rr_counter;
85
86   unsigned char *vincore;       
87   unsigned int vincorelen;
88
89   Id **attrs;                   /* un-internalized attributes */
90   unsigned char *attrdata;      /* their string data space */
91   unsigned int attrdatalen;
92   Id *attriddata;               /* their id space */
93   unsigned int attriddatalen;
94
95 } Repodata;
96
97 #define REPODATA_AVAILABLE      0
98 #define REPODATA_STUB           1
99 #define REPODATA_ERROR          2
100 #define REPODATA_STORE          3
101
102 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);
103 const char *repodata_lookup_str(Repodata *data, Id entry, Id keyid);
104 int repodata_lookup_num(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 void repodata_merge_attrs (Repodata *data, Id dest, Id src);
116
117 void repodata_internalize(Repodata *data);
118
119 Id repodata_str2dir(Repodata *data, const char *dir, int create);
120
121 unsigned int repodata_compress_page(unsigned char *, unsigned int, unsigned char *, unsigned int);
122 void repodata_read_or_setup_pages(Repodata *data, unsigned int pagesz, unsigned int blobsz);
123
124 #endif /* SATSOLVER_REPODATA_H */