.. _program_listing_file_include_zim_zim.h: Program Listing for File zim.h ============================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/zim/zim.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* * Copyright (C) 2020-2021 Veloman Yunkan * Copyright (C) 2018-2020 Matthieu Gautier * Copyright (C) 2006 Tommi Maekitalo * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef ZIM_ZIM_H #define ZIM_ZIM_H #include #include #ifdef __GNUC__ #define DEPRECATED __attribute__((deprecated)) #elif defined(_MSC_VER) #define DEPRECATED __declspec(deprecated) #else #pragma message("WARNING: You need to implement DEPRECATED for this compiler") #define DEPRECATED #endif #include #if defined(_MSC_VER) && defined(LIBZIM_EXPORT_DLL) #define LIBZIM_API __declspec(dllexport) #else #define LIBZIM_API #endif namespace zim { // An index of an entry (in a zim file) typedef uint32_t entry_index_type; // An index of an cluster (in a zim file) typedef uint32_t cluster_index_type; // An index of a blog (in a cluster) typedef uint32_t blob_index_type; // The size of something (entry, zim, cluster, blob, ...) typedef uint64_t size_type; // An offset. typedef uint64_t offset_type; struct LIBZIM_API OpenConfig { OpenConfig(); OpenConfig& preloadXapianDb(bool load) { m_preloadXapianDb = load; return *this; } OpenConfig preloadXapianDb(bool load) const { return OpenConfig(*this).preloadXapianDb(load); } OpenConfig& preloadDirentRanges(int nbRanges) { m_preloadDirentRanges = nbRanges; return *this; } OpenConfig preloadDirentRanges(int nbRanges) const { return OpenConfig(*this).preloadDirentRanges(nbRanges); } bool m_preloadXapianDb; int m_preloadDirentRanges; }; struct FdInput { // An open file descriptor int fd; // The (absolute) offset of the data "pointed" by FdInput in fd. offset_type offset; // The size (length) of the data "pointed" by FdInput size_type size; FdInput(int fd, offset_type offset, size_type size): fd(fd), offset(offset), size(size) {} }; enum class Compression { None = 1, // intermediate values correspond to compression // methods that are no longer supported Zstd = 5 }; static const char MimeHtmlTemplate[] = "text/x-zim-htmltemplate"; enum class IntegrityCheck { CHECKSUM, DIRENT_PTRS, DIRENT_ORDER, TITLE_INDEX, CLUSTER_PTRS, CLUSTERS_OFFSETS, DIRENT_MIMETYPES, // End of integrity check types. // COUNT must be the last one and denotes the count of all checks COUNT }; struct ItemDataDirectAccessInfo { std::string filename; offset_type offset; explicit ItemDataDirectAccessInfo() : filename(), offset() {} ItemDataDirectAccessInfo(const std::string& filename, offset_type offset) : filename(filename), offset(offset) {} bool isValid() const { return !filename.empty(); } }; } #endif // ZIM_ZIM_H