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 s_Attrblobpage
16 /* page_size == 0 means the page is not backed by some file storage.
17 Otherwise it is L*2+(compressed ? 1 : 0), with L being the data
19 unsigned int page_offset;
20 unsigned int page_size;
23 typedef struct s_Repopagestore {
24 int pagefd; /* file descriptor we're paging from */
25 long file_offset; /* pages in file start here */
27 unsigned char *blob_store;
28 unsigned int num_pages;
30 /* mapped_at[page] == -1 --> not loaded, otherwise offset into
31 store->blob_store. The size of the mapping is REPOPAGE_BLOBSIZE
32 except for the last page. */
33 unsigned int *mapped_at;
35 Attrblobpage *file_pages;
37 /* mapped[i] is -1 if nothing is mapped at logical page I,
38 otherwise it contains the page number (of the mapped page). */
41 unsigned int rr_counter;
48 void repopagestore_init(Repopagestore *store);
49 void repopagestore_free(Repopagestore *store);
51 /* load pages pstart..pend into consecutive memory, return address */
52 unsigned char *repopagestore_load_page_range(Repopagestore *store, unsigned int pstart, unsigned int pend);
54 /* compress a page, return compressed len */
55 unsigned int repopagestore_compress_page(unsigned char *page, unsigned int len, unsigned char *cpage, unsigned int max);
57 /* setup page data for repodata_load_page_range */
58 int repopagestore_read_or_setup_pages(Repopagestore *store, FILE *fp, unsigned int pagesz, unsigned int blobsz);
60 void repopagestore_disable_paging(Repopagestore *store);
66 #endif /* LIBSOLV_REPOPAGE_H */