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 /* page_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
24 unsigned int page_offset;
25 unsigned int page_size;
28 typedef struct _Repopagestore {
29 int pagefd; /* file descriptor we're paging from */
30 long file_offset; /* pages in file start here */
32 unsigned char *blob_store;
34 unsigned int num_pages;
36 /* mapped[i] is zero if nothing is mapped at logical page I,
37 otherwise it contains the pagenumber plus one (of the mapped page). */
40 unsigned int rr_counter;
43 void repopagestore_init(Repopagestore *store);
44 void repopagestore_free(Repopagestore *store);
46 /* load pages pstart..pend into consecutive memory, return address */
47 unsigned char *repopagestore_load_page_range(Repopagestore *store, unsigned int pstart, unsigned int pend);
49 /* compress a page, return compressed len */
50 unsigned int repopagestore_compress_page(unsigned char *page, unsigned int len, unsigned char *cpage, unsigned int max);
52 /* setup page data for repodata_load_page_range */
53 int repopagestore_read_or_setup_pages(Repopagestore *store, FILE *fp, unsigned int pagesz, unsigned int blobsz);
55 void repopagestore_disable_paging(Repopagestore *store);
57 #endif /* LIBSOLV_REPOPAGE_H */