- use correct defaults for rpm5, put tmpspace in extra struct
[platform/upstream/libsolv.git] / src / repopage.h
1 /*
2  * Copyright (c) 2007-2008, Novell Inc.
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 #ifndef SATSOLVER_REPOPAGE_H
9 #define SATSOLVER_REPOPAGE_H
10
11 #define BLOB_PAGEBITS 15
12 #define BLOB_PAGESIZE (1 << BLOB_PAGEBITS)
13
14 typedef struct _Attrblobpage
15 {
16   /* mapped_at == -1  --> not loaded, otherwise offset into
17      store->blob_store.  The size of the mapping is BLOB_PAGESIZE
18      except for the last page.  */
19   unsigned int mapped_at;
20   long file_offset;
21   /* file_size == 0 means the page is not backed by some file storage.
22      Otherwise it is L*2+(compressed ? 1 : 0), with L being the data
23      length.  */
24   long file_size;
25 } Attrblobpage;
26
27 typedef struct _Repopagestore {
28   int pagefd;   /* file descriptor we're paging from */
29
30   unsigned char *blob_store;
31   Attrblobpage *pages;
32   unsigned int num_pages;
33
34   /* mapped[i] is zero if nothing is mapped at logical page I,
35    otherwise it contains the pagenumber plus one (of the mapped page).  */
36   unsigned int *mapped;
37   unsigned int nmapped, ncanmap;
38   unsigned int rr_counter;
39 } Repopagestore;
40
41 void repopagestore_init(Repopagestore *store);
42 void repopagestore_free(Repopagestore *store);
43
44 /* load pages pstart..pend into consecutive memory, return address */
45 unsigned char *repopagestore_load_page_range(Repopagestore *store, unsigned int pstart, unsigned int pend);
46
47 /* compress a page, return compressed len */
48 unsigned int repopagestore_compress_page(unsigned char *page, unsigned int len, unsigned char *cpage, unsigned int max);
49
50 /* setup page data for repodata_load_page_range */
51 int repopagestore_read_or_setup_pages(Repopagestore *store, FILE *fp, unsigned int pagesz, unsigned int blobsz);
52
53 void repopagestore_disable_paging(Repopagestore *store);
54
55 #endif  /* SATSOLVER_REPOPAGE_H */