2 * Copyright (c) 2007-2011, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
8 #ifndef LIBSOLV_REPOPAGE_H
9 #define LIBSOLV_REPOPAGE_H
11 #define REPOPAGE_BLOBBITS 15
12 #define REPOPAGE_BLOBSIZE (1 << REPOPAGE_BLOBBITS)
14 typedef struct _Attrblobpage
16 /* mapped_at == -1 --> not loaded, otherwise offset into
17 store->blob_store. The size of the mapping is REPOPAGE_BLOBSIZE
18 except for the last page. */
19 unsigned int mapped_at;
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
27 typedef struct _Repopagestore {
28 int pagefd; /* file descriptor we're paging from */
30 unsigned char *blob_store;
32 unsigned int num_pages;
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). */
37 unsigned int nmapped, ncanmap;
38 unsigned int rr_counter;
41 void repopagestore_init(Repopagestore *store);
42 void repopagestore_free(Repopagestore *store);
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);
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);
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);
53 void repopagestore_disable_paging(Repopagestore *store);
55 #endif /* LIBSOLV_REPOPAGE_H */