ebook-tools-0.2.2/0000755000530500000060000000000012021410400013520 5ustar elylevysystemebook-tools-0.2.2/README0000644000530500000060000000011612021410400014376 0ustar elylevysystemPlease contact me if you are willing to help Ely Levy (elylevy@cs.huji.ac.il)ebook-tools-0.2.2/LICENSE0000644000530500000060000000211212021410400014521 0ustar elylevysystemThe MIT License Copyright (c) 2008 Ely Levy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. loginebook-tools-0.2.2/CMakeLists.txt0000644000530500000060000000164012021410400016261 0ustar elylevysystemproject (EBOOK-TOOLS C) cmake_minimum_required(VERSION 2.4.0) #set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(LIBRARY_OUTPUT_PATH ${EBOOK-TOOLS_BINARY_DIR}/libs) set(EXECUTABLE_OUTPUT_PATH ${EBOOK-TOOLS_BINARY_DIR}/bin) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) set(LIB_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)") find_package(LibXml2 REQUIRED) find_package(LibZip REQUIRED) if(CMAKE_C_COMPILER_ID MATCHES GNU) set(CMAKE_C_FLAGS "-Wall -W -Wno-long-long -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -Wshadow -fno-common ${CMAKE_C_FLAGS}") endif(CMAKE_C_COMPILER_ID MATCHES GNU) if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif(MSVC) INCLUDE("${CMAKE_MODULE_PATH}/TargetDoc.cmake" OPTIONAL) add_subdirectory (src) ebook-tools-0.2.2/libs/0000755000530500000060000000000012021410400014451 5ustar elylevysystemebook-tools-0.2.2/bin/0000755000530500000060000000000012021410400014270 5ustar elylevysystemebook-tools-0.2.2/doc/0000755000530500000060000000000012021410400014265 5ustar elylevysystemebook-tools-0.2.2/doxy.config.in0000644000530500000060000014756712021410400016323 0ustar elylevysystem# Doxyfile 1.4.5 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = "@PROJECT_NAME@" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = @PROJECT_VERSION@ # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = doc # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, # Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, # Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, # Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, # Swedish, and Ukrainian. OUTPUT_LANGUAGE = English # This tag can be used to specify the encoding used in the generated output. # The encoding is not always determined by the language that is chosen, # but also whether or not the output is meant for Windows or non-Windows users. # In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES # forces the Windows encoding (this is the default for the Windows binary), # whereas setting the tag to NO uses a Unix-style encoding (the default for # all platforms other than Windows). USE_WINDOWS_ENCODING = YES # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = @CMAKE_CURRENT_SOURCE_DIR@ # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = @CMAKE_CURRENT_SOURCE_DIR@/ # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explicit @brief command for a brief description. JAVADOC_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 2 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for Java. # For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to # include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. # BUILTIN_STL_SUPPORT = NO # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = YES # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = YES # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is YES. SHOW_DIRECTORIES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from the # version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = @DOXY_WARN_FORMAT@ # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = doc/doxy.log #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = @CMAKE_CURRENT_SOURCE_DIR@ \ @CMAKE_CURRENT_BINARY_DIR@ # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py FILE_PATTERNS = *.cpp \ *.cc \ *.h \ *.hh \ *.hpp \ *.dox # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/Base/Common/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/Base/Debug/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/Base/Math/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/Base/Image/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/Base/Geometry/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/MathAlgo/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/Geometry/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/CornerDetector/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/Image/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/StateEstimator/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/Matcher2D/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/Utils/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/Gui/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/FeatureDetector/Examples \ @CMAKE_CURRENT_SOURCE_DIR@/doc \ @CMAKE_CURRENT_SOURCE_DIR@ # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = *.cpp \ *.cc \ *.h \ *.hh \ INSTALL DEPENDENCIES CHANGELOG LICENSE LGPL # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = YES # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/doc \ @CMAKE_CURRENT_SOURCE_DIR@/Tests/data \ @CMAKE_CURRENT_SOURCE_DIR@ # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = NO # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 2 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = YES # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = YES # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. #LATEX_CMD_NAME = latex LATEX_CMD_NAME = @LATEX_COMPILER@ # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. #MAKEINDEX_CMD_NAME = makeindex MAKEINDEX_CMD_NAME = @MAKEINDEX_COMPILER@ # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = YES # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = doc/html/@PROJECT_NAME@.TAGFILE # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = YES # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = @DOXYGEN_DOT_FOUND@ # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # UML_LOOK = YES # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will # generate a call dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. CALL_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = @DOXYGEN_DOT_EXECUTABLE_PATH@ # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1280 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that a graph may be further truncated if the graph's # image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH # and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), # the graph is not depth-constrained. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, which results in a white background. # Warning: Depending on the platform used, enabling this option may lead to # badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. # JW # DOT_MULTI_TARGETS = NO DOT_MULTI_TARGETS = YES # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. # JW SEARCHENGINE = NO SEARCHENGINE = YESebook-tools-0.2.2/debian/0000755000530500000060000000000012021410400014742 5ustar elylevysystemebook-tools-0.2.2/debian/rules0000755000530500000060000000037312021410400016025 0ustar elylevysystem#!/usr/bin/make -f #export DH_VERBOSE=1 DEB_DH_INSTALL_SOURCEDIR = debian/tmp DEB_DH_STRIP_ARGS = --dbg-package=libepub0 include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/cmake.mk include /usr/share/cdbs/1/rules/utils.mk ebook-tools-0.2.2/debian/copyright0000644000530500000060000000304212021410400016674 0ustar elylevysystemThis package was debianized by Pino Toscano on Sun, 06 Apr 2008 17:23:13 +0200. It was downloaded from Upstream Author: Ely Levy Copyright (c) 2008 Ely Levy License: The ebook-tools are licensed under the terms of the MIT license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The Debian packaging is (C) 2008, Pino Toscano and is licensed under the GPL, see `/usr/share/common-licenses/GPL'. ebook-tools-0.2.2/debian/changelog0000644000530500000060000000022612021410400016614 0ustar elylevysystemebook-tools (0.1.0-1) unstable; urgency=low * Initial release (Closes: #475513) -- Pino Toscano Sun, 06 Apr 2008 17:23:13 +0200 ebook-tools-0.2.2/debian/compat0000644000530500000060000000000212021410400016140 0ustar elylevysystem5 ebook-tools-0.2.2/debian/libepub-dev.install0000644000530500000060000000003612021410400020527 0ustar elylevysystemusr/include/* usr/lib/lib*.so ebook-tools-0.2.2/debian/watch0000644000530500000060000000024312021410400015772 0ustar elylevysystem# Compulsory line, this is a version 3 file version=3 # find new files on sourceforge, for devscripts >= 2.9 http://sf.net/ebook-tools/ebook-tools-(.*)\.tar\.gz ebook-tools-0.2.2/debian/epub-utils.install0000644000530500000060000000001212021410400020414 0ustar elylevysystemusr/bin/* ebook-tools-0.2.2/debian/control0000644000530500000060000000403112021410400016343 0ustar elylevysystemSource: ebook-tools Priority: optional Maintainer: Pino Toscano Build-Depends: debhelper (>= 5), cmake (>= 2.4.0), cdbs (>= 0.4.51), libxml2-dev, libzip-dev Standards-Version: 3.7.3 Section: libs Package: libepub-dev Section: libdevel Architecture: any Depends: libepub0 (= ${binary:Version}) Description: library and tools to work with the EPub file format The ebook-tools provide ways for accessing and converting different ebook file formats. . This C library is free and portable. It includes methods to parse EPub files and extract their contents. . This package includes development headers and libraries. Package: libepub0 Section: libs Architecture: any Depends: ${shlibs:Depends} Description: library and tools to work with the EPub file format The ebook-tools provide ways for accessing and converting different ebook file formats. . This C library is free and portable. It includes methods to parse EPub files and extract their contents. Package: ebook-tools-dbg Section: libdevel Architecture: any Priority: extra Depends: libc6-dbg, libepub0 (= ${binary:Version}) Description: library and tools to work with the EPub file format The ebook-tools provide ways for accessing and converting different ebook file formats. . This C library is free and portable. It includes methods to parse EPub files and extract their contents. . This package includes the debug symbols for the library. Package: epub-utils Section: graphics Architecture: any Depends: libc6, libepub0 (= ${binary:Version}) Suggests: clit, zip Description: library and tools to work with the EPub file format The ebook-tools provide ways for accessing and converting different ebook file formats. . This C library is free and portable. It includes methods to parse EPub files and extract their contents. . This package contains the following utilities: - einfo : provides some basic info about an EPub document, such as metadata, reading order, etc. - lit2epub : converts a LIT file to EPub (using clit). ebook-tools-0.2.2/debian/libepub0.install0000644000530500000060000000002212021410400020026 0ustar elylevysystemusr/lib/lib*.so.* ebook-tools-0.2.2/INSTALL0000644000530500000060000000116212021410400014551 0ustar elylevysystemRequirements ------------ This project depends on: - libzip which you can get from http://www.nih.at/libzip/ - libxml2 which you can get from http://xmlsoft.org/ - cmake (www.cmake.org) To use the lit2epub script you also need to have: - clit (or convertlit) from http://www.convertlit.com/ - zip I used the one from http://www.info-zip.org/ note that clit might be not legal in some countries, so check it before you decide to download it. Install ------- Installing is pretty simple cmake . works fine in most cases do ccmake . if you have to fiddle with the configuration for some reason. make make install ebook-tools-0.2.2/src/0000755000530500000060000000000012021410400014307 5ustar elylevysystemebook-tools-0.2.2/src/CMakeLists.txt0000644000530500000060000000006512021410400017050 0ustar elylevysystemadd_subdirectory (libepub) add_subdirectory (tools) ebook-tools-0.2.2/src/libepub/0000755000530500000060000000000012021410400015731 5ustar elylevysystemebook-tools-0.2.2/src/libepub/linklist.h0000644000530500000060000003426112021410400017741 0ustar elylevysystem/* LinkList.H -- ANSI C Linked List Container Type Handles Lists, Queues, Stacks, Splay Trees, and custom list types via one consistant interface. - Written by Jeff Hay, jrhay@lanl.gov - If you find errors in this library, please let me know! What It Does: - Creates, maintains, and destroys any type of linked memory structure (singly/doubly linked lists, queues, stacks, etc) effeciently and without memory leaks. - Any user-specified data may be held within structure nodes. - Allows user-definable memory allocation and deallocation routines to be used in place of standard malloc() and free() calls. - Any number and types of linked memory structures may be created (subject only to memory limitations) - "Should be" portable to any ANSI C compilent platform Stuff To Do Yet: - Add functionallity to be able to interrupt list maintence routines at any point and still maintain list continuity (for multi-processor shared memory environments) The object file compiled from this library is around 5K depending on operating platform. */ #ifndef __c_LINKLIST__ #define __c_LINKLIST__ /* NOTE: All functions assume the list data structures are UNTOUCHED expect by functions in this library. Bad things could happen if you muck with them at all. (unless you know what you are doing.... ;) This library has been through several incarnations, each one adding features while maintaining compatibility with the previous versions. The result is a confusing number of functions. For new programs, the only functions you need are: List Creation - NewListAlloc(), AddNode() List Destruction - FreeList(), DelNode() List Transversal - NextNode(), PrevNode(), IndexNode() List Manipulation - GetNode(), GetNodeData() All other functions are either internal-use functions or obsolete definitions to maintain source compatiblity for programs written to older versions of this library. Note also that if using the library to maintain binary search trees, the List Transversal functions should not normally be used. See the last section of this header file for extended documentation on all functions. */ /* Will use the DALLOC library if "dalloc.h" is included on the compiler command line */ /* Uncomment the following line to compile an executable from LinkList.C that will demonstrate and test the functions contained in this library. (or define LINKLIST_TEST on the compiler command line ("make linklist") */ /* #define LINKLIST_TEST 1 */ /* ------- Include files used by this library ------- */ #include #include /* -------- List Flags and Parameters -------- */ /* List Parameters */ #define LISTADDCURR 0x300 /* Add New Node At Current Record In List */ #define LISTADDHEAD 0x100 /* Add New Nodes At Head Of List */ #define LISTADDTAIL 0x200 /* Add New Nodes At Tail Of List */ #define LISTADDSPLAY 0x400 /* Add New Nodes As A Splay Tree */ #define LISTDELCURR 0x030 /* Delete Nodes At Current Record */ #define LISTDELHEAD 0x010 /* Delete Nodes At Head Of List */ #define LISTDELTAIL 0x020 /* Delete Nodes At Tail Of List */ #define LISTDELSPLAY 0x040 /* Delete Nodes As A Splay Tree */ #define LISTREADCURR 0x003 /* Read List At Current Node */ #define LISTREADHEAD 0x001 /* Read Head Of List */ #define LISTREADTAIL 0x002 /* Read Tail Of List */ #define LISTDELREAD 0x1000 /* Delete Node On Reading */ #define LISTCIRCULAR 0x2000 /* Circular List - Head->Next=Tail, etc */ #define LISTBTREE 0x4000 /* List is actually a binary tree */ /* Masks of List Parameters */ #define LISTADDMASK 0xF00 /* Add New Node Method */ #define LISTDELMASK 0x0F0 /* Delete Node Method */ #define LISTREADMASK 0x00F /* Read Node Method */ #define LISTFLAGMASK 0xF000 /* Operation Flags */ /* Common Data Structure Types */ #define LIST (LISTADDCURR | LISTREADCURR | LISTDELCURR) #define FIFO (LISTADDTAIL | LISTREADHEAD | LISTDELHEAD) #define LIFO (LISTADDHEAD | LISTREADHEAD | LISTDELHEAD) #define QUEUE (FIFO | LISTDELREAD) #define STACK (LIFO | LISTDELREAD) #define CIRCULAR_QUEUE (QUEUE | LISTCIRCULAR) #define STREE (LISTBTREE | LISTADDSPLAY | LISTDELSPLAY | LISTREADCURR) /* -------- Possible return values of functions in this library -------- */ #define LLIST_NOERROR 0 /* No problem! */ #define LLIST_NULL 1 /* Bad value passed to function */ #define LLIST_ERROR -1 /* Misc. program/library error. Serious trouble! */ #define LLIST_OK LLIST_NOERROR /* duplicate definitions for compatibility */ #define LLIST_BADVALUE LLIST_NULL /* -------- List data structures -------- */ typedef void (*ListFreeFunc)(void *); /* Function to release memory stored within a list (free() syntax) */ typedef void *(* ListAlloc)(size_t size); /* Memory allocation procedure to use for this list (malloc() syntax) */ typedef int (* NodeCompareFunc)(void *, void *); /* Function used to compare nodes for list sorting. The two passed pointers are two data elements from nodes of a list. CompareFunc must return: 1 iff First Node > Second Node 0 iff First Node = Second Node -1 iff First Node < Second Node Results are undefined if one or both pointers are NULL. (note that this definition is compatible with strcmp() and related functions) */ typedef int (* ListDumpFunc)(void *); /* Function to dump the data of a node to the screen */ typedef struct ListNode* listnodePtr; typedef struct ListNode { void *Data; /* Data stored at this node (user-defined) */ listnodePtr Next, /* Next Node in List, Right Child in Binary Tree */ Prev; /* Previous Node in List, Left Child in Binary Tree */ } listnode; typedef struct LList* listPtr; typedef struct LList { listnodePtr Current, /* Last Accessed Node */ Head, /* Head of List, Root of Binary Tree */ Tail; /* Tail of List */ int Size, /* Number of nodes in List or Binary Tree */ Flags; /* Flags associated with List/Tree */ ListAlloc memalloc; /* malloc()-type procedure to use */ ListFreeFunc memfree; /* free()-type procedure to use */ NodeCompareFunc compare; /* Function to use to compare nodes */ } llist; /* ------- Make sure we have DALLOC (or similarly-named macros) -------- */ #ifndef DMALLOC #define DMALLOC malloc #endif #ifndef DFREE #define DFREE dfree #endif #ifndef DCOUNT #define DCOUNT dcount #endif /* -------- Function Prototypes -------- */ listPtr NewListAlloc(int ListType, ListAlloc Lalloc, ListFreeFunc Lfree, NodeCompareFunc Cfunc); /* Create a brand new list structure. The structrue is defined by ListType, which is a logical OR of the List Parameters defined above. Use the specified allocation and free function to allocate dynamic memory to the list. If "alloc" or "free" are NULL, default to malloc() and free() (respectively) from stdlib. If "Cfunc" is NULL, don't do comparisons. Returns Pointer to a new list NULL on error (Lalloc() procedure failed) */ #define NewList(Type) NewListAlloc(Type, NULL, NULL, NULL) /* Macro definition of: listPtr NewList(int ListType); for compatibility with previous versions of library */ listnodePtr NewListNode(listPtr List, void *Data); /* Creates a new node for the specified list. Memory is allocated with the list alloc procedure. Data is a pointer to any kind of data or may be NULL. If List is NULL, node is created using malloc(). Returns Pointer to the new node NULL on error (alloc failed) */ #define NewNode(Data) NewListNode(NULL, Data) /* Macro definition of: listnodePtr NewNode(void *Data); for compatibility with previous versions of library */ void *GetNode(listPtr List); /* Reads the next node in the list (as specified at list creation with one of the LISTREAD* properties). If list has unknown LISTREAD* property, returns as LISTREADCURR. If LISTDELREAD is a property of the list, the node is automatically deleted (note that the node DATA is *not* free()'d). Returns Pointer to the node data NULL if List is NULL or empty (or list read property is unknown) */ void *FindNode(listPtr List, void *Data); /* Finds a node in the list for which the list compare function specified at list creation returns 0 when compared with "Data". Sets List->Current to the found node, and returns found node's data. Returns Pointer to the node data NULL if list empty if no list compare function if no node matching data was found in list */ void *BTFind(listPtr List, void *Data); /* Performs "FindNode" operation when list is a binary tree; called automatically by FindNode() when list has LISTBTREE property set. */ void *GetNodeData(listnodePtr Node); /* Returns the data contained in the specified node, or NULL if Node is empty*/ int AddNode(listPtr List, listnodePtr Node); /* Adds a node to the list in the location specified at list creation by one of the LISTADD* properties. If the LISTADD property is unknown for any reason (program error), the node is added at the current list position. Node must be created by NewListNode. Current list pointer is set to the newly added node. Returns LLIST_NOERROR on success LLIST_NULL if either List or Node are NULL LLIST_ERROR on undefined program error */ int InsertList(listPtr List, listnodePtr Node); int HeadList(listPtr List, listnodePtr Node); int TailList(listPtr List, listnodePtr Node); int SplayInsertList(listPtr List, listnodePtr Node); /* These functions add the specified node to the specified list at the either the current position, the head of the list, the tail of the list, ,or in a splay pattern, respectively. All assume the node has been init'd by NewNode() and all set List->Current to the newly added node. These functions should not normally be called directly by user programs (AddNode() will call the approrpiate function for the list) All return LLIST_NOERROR on success LLIST_NULL if either List or Node are NULL */ int DelNode(listPtr List); /* Deletes a node from the list. The node deleted is specified at list creation by one of the LISTDEL* properties. If the LISTDEL property is unknown for any reson, the "current" node is deleted. Current list position is set to the next logical node in the list (or NULL). Note: Note DATA is *not* deleted. Returns LLIST_NOERROR on success LLIST_NULL if List is NULL LLIST_ERROR on undefined program error */ int RemoveList(listPtr List); int DelHeadList(listPtr List); int DelTailList(listPtr List); /* These functions delete the node at either the current list position, the head of the list, the tail of the list, or as a splay pattern, respectively. All set List->Current to the next node in the list (Node->Next). These functions should not normally be called directly by user programs (DelNode() will call the approrpiate function for the list) All Return LLIST_NOERROR on success LLIST_NULL if List is NULL */ void *NextNode(listPtr List); /* Step to the next logical node in the list. For lists with LISTBTREE set, steps to the right child of the current node. Returns NULL if List or next node is empty Pointer to the next node's data on success */ void *PrevNode(listPtr List); /* Step to the previous logical node in the list. For lists with LISTBTREE set, steps to the left child of the current node. Returns NULL if List or next node is empty Pointer to the next node's data on success */ void *IndexNode(listPtr List, int Index); /* Step to the logical node numbed "Index" in the List. The head of the list is index "1"; the tail is index "List->Size". If LISTBTREE is set, this function always returns NULL (Indexing makes no sense). Returns NULL if List or indexed node is empty if Index > size of list Pointer to the index node's data on success */ int FreeList(listPtr List, ListFreeFunc DataFree); /* Deletes entire list structure and frees all memory. List is undefined after this call. "DataFree" is an optional function used to free the memory allocated for each node's data (ie, if the data is a dynamic structure, etc); it may be NULL. It will *not* be called for empty nodes (node->data == NULL). If this function returns with anything other then LLIST_NOERROR, an error was encountered deleting a node from the list. List is in undefined state. */ void SwapList(listPtr List); /* Swaps the current node in the list with the next node in the list. No function if current node is tail of list. */ void SortList(listPtr List); /* Preforms a slow sort on the list. Sort is handled in-place. Current node is head of list after sort. Does not attempt to sort lists with LISTBTREE property set. */ void *SplayList(listPtr List, void *Data); /* Performs a splay operation on the list. The list is assumed to be a splay tree. Finds the node in the tree that matches "Data" and moves that node (or the closest node less then data) to the root of the tree, preserving the inorder transversal of the tree. Returns Pointer to node data if found NULL if List is NULL if "Data" not found in Tree */ int IntCompare(int *First, int* Second); int StringCompare(char *First, char* Second); int DoubleCompare(double *First, double* Second); /* These are suitable NodeCompareFunc functions for three common types of nodes. Provided just to make life a little easier... */ int DumpList(listPtr List, ListDumpFunc DataDump); /* Print List data using the DataDump function for Node Data Elements */ #ifdef LINKLIST_TEST int PrintList(listPtr List, char *DataFmt); /* Display the contents of a list. Provided mainly as an example of how to transverse list if needed. Written for an old version of this library and never updated. */ int PrintTree(listPtr List, char *DataFmt); /* Prints the contents and structure of a Tree using DataFmt as the printf() format for Node Data Elements. Called by PrintList as appropriate. */ #endif #endif /* __c_LINKLIST__ */ ebook-tools-0.2.2/src/libepub/epublib.h0000644000530500000060000001715012021410400017530 0ustar elylevysystem#ifndef EPUBLIB_H #define EPUBLIB_H 1 // generally needed includes #include #include #include // For opening the zip file #include #include // For parsing xml #include // For list stuff #include "linklist.h" #include "epub_shared.h" // General definitions #ifdef _WIN32 # define PATH_SEPARATOR '\\' #else # define PATH_SEPARATOR '/' #endif #ifdef __GNUC__ # define PRINTF_FORMAT(si, ftc) __attribute__ ((format (printf, si, ftc))) #else # define PRINTF_FORMAT(si, ftc) #endif // MSVC-specific definitions #ifdef _MSC_VER # define strdup _strdup #endif /////////////////////////////////////////////////////////// // OCF definions /////////////////////////////////////////////////////////// #define METAINFO_DIR "META-INF" #define MIMETYPE_FILENAME "mimetype" #define CONTAINER_FILENAME "container.xml" #define MANIFEST_FILENAME "manifest.xml" #define METADATA_FILENAME "metadata.xml" #define SIGNATURES_FILENAME "signatures.xml" #define ENCRYPTION_FILENAME "encryption.xml" #define RIGHTS_FILENAME "rights.xml" // An OCF root struct root { xmlChar *mediatype; // media type (mime) xmlChar *fullpath; // full path to the root }; struct ocf { char *datapath; // The path that the data files relative to char *filename; // The ebook filename struct zip *arch; // The epub zip char *mimetype; // For debugging listPtr roots; // list of OCF roots struct epub *epub; // back pointer }; struct meta { xmlChar *name; xmlChar *content; }; struct id { xmlChar *id; xmlChar *scheme; xmlChar *string; }; struct date { xmlChar *date; xmlChar *event; }; struct creator { xmlChar *name; xmlChar *fileAs; xmlChar *role; }; struct metadata { listPtr id; listPtr title; listPtr creator; listPtr contrib; listPtr subject; listPtr publisher; listPtr description; listPtr date; listPtr type; listPtr format; listPtr source; listPtr lang; listPtr relation; listPtr coverage; listPtr rights; listPtr meta; }; struct manifest { xmlChar *nspace; xmlChar *modules; xmlChar *id; xmlChar *href; xmlChar *type; xmlChar *fallback; xmlChar *fbStyle; }; struct guide { xmlChar *type; xmlChar *title; xmlChar *href; }; struct site { xmlChar *title; xmlChar *href; }; struct tour { xmlChar *id; xmlChar *title; listPtr sites; }; // Struct for navLabel and navInfo struct tocLabel { xmlChar *lang; xmlChar *dir; xmlChar *text; }; // struct for navPoint, pageTarget, navTarget struct tocItem { xmlChar *id; xmlChar *src; xmlChar *class; xmlChar *type; //pages listPtr label; int depth; int playOrder; int value; }; // struct for navMap, pageList, navList struct tocCategory { xmlChar *id; xmlChar *class; listPtr info; //tocLabel listPtr label; //tocLabel listPtr items; //tocItem }; // General toc struct struct toc { struct tocCategory *navMap; struct tocCategory *pageList; struct tocCategory *navList; listPtr playOrder; }; struct spine { xmlChar *idref; int linear; //bool }; struct opf { char *name; xmlChar *tocName; struct epub *epub; struct metadata *metadata; struct toc *toc; // must in opf 2.0 listPtr manifest; listPtr spine; int linearCount; // might be NULL listPtr guide; listPtr tours; }; struct epuberr { char lastStr[1025]; const char *str; int len; int type; /* for str: 0 = lastStr, 1 = external */ }; extern const char _epub_error_oom[]; #define _epub_err_set_const_str(_err, _err_string) \ do { \ (_err)->str = _err_string; \ (_err)->type = 1; \ } while (0) #define _epub_err_set_str(_err, _err_string, _err_string_len) \ do { \ strncpy((_err)->lastStr, _err_string, _err_string_len); \ (_err)->len = _err_string_len; \ (_err)->str = (_err)->lastStr; \ (_err)->type = 0; \ } while (0) #define _epub_err_set_oom(_epub_err) _epub_err_set_const_str(_epub_err, _epub_error_oom) // general structs struct epub { struct ocf *ocf; struct opf *opf; struct epuberr error; int debug; }; enum { DEBUG_NONE, DEBUG_ERROR, DEBUG_WARNING, DEBUG_INFO, DEBUG_VERBOSE }; struct eiterator { enum eiterator_type type; struct epub *epub; int opt; listnodePtr curr; char *cache; }; struct tit_info { char *label; int depth; char *link; }; struct titerator { enum titerator_type type; struct epub *epub; int opt; listnodePtr next; struct tit_info cache; int valid; }; // Ocf functions struct ocf *_ocf_parse(struct epub *epub, const char *filename); void _ocf_dump(struct ocf *ocf); void _ocf_close(struct ocf *ocf); struct zip *_ocf_open(struct ocf *ocf, const char *fileName); int _ocf_get_file(struct ocf *ocf, const char *filename, char **fileStr); int _ocf_get_data_file(struct ocf *ocf, const char *filename, char **fileStr); int _ocf_check_file(struct ocf *ocf, const char *filename); char *_ocf_root_by_type(struct ocf *ocf, const char *type); char *_ocf_root_fullpath_by_type(struct ocf *ocf, const char *type); // Parsing ocf int _ocf_parse_container(struct ocf *ocf); int _ocf_parse_mimetype(struct ocf *ocf); // parsing opf struct opf *_opf_parse(struct epub *epub, char *opfStr); void _opf_dump(struct opf *opf); void _opf_close(struct opf *opf); void _opf_parse_metadata(struct opf *opf, xmlTextReaderPtr reader); void _opf_parse_spine(struct opf *opf, xmlTextReaderPtr reader); void _opf_parse_manifest(struct opf *opf, xmlTextReaderPtr reader); void _opf_parse_guide(struct opf *opf, xmlTextReaderPtr reader); void _opf_parse_tours(struct opf *opf, xmlTextReaderPtr reader); // parse toc void _opf_parse_toc(struct opf *opf, char *tocStr, int size); void _opf_parse_navlist(struct opf *opf, xmlTextReaderPtr reader); void _opf_parse_navmap(struct opf *opf, xmlTextReaderPtr reader); void _opf_parse_pagelist(struct opf *opf, xmlTextReaderPtr reader); struct tocLabel *_opf_parse_navlabel(struct opf *opf, xmlTextReaderPtr reader); void _opf_free_toc_category(struct tocCategory *tc); void _opf_free_toc(struct toc *toc); struct toc *_opf_init_toc(); struct tocCategory *_opf_init_toc_category(); xmlChar *_opf_label_get_by_lang(struct opf *opf, listPtr label, char *lang); xmlChar *_opf_label_get_by_doc_lang(struct opf *opf, listPtr label); struct manifest *_opf_manifest_get_by_id(struct opf *opf, xmlChar* id); // epub functions struct epub *epub_open(const char *filename, int debug); void _epub_print_debug(struct epub *epub, int debug, const char *format, ...) PRINTF_FORMAT(3, 4); char *epub_last_errStr(struct epub *epub); // List operations void _list_free_root(struct root *data); void _list_free_creator(struct creator *data); void _list_free_date(struct date *date); void _list_free_id(struct id *id); void _list_free_meta(struct meta *meta); void _list_free_spine(struct spine *spine); void _list_free_manifest(struct manifest *manifest); void _list_free_guide(struct guide *guide); void _list_free_tours(struct tour *tour); void _list_free_toc_label(struct tocLabel *tl); void _list_free_toc_item(struct tocItem *ti); int _list_cmp_root_by_mediatype(struct root *root1, struct root *root2); int _list_cmp_manifest_by_id(struct manifest *m1, struct manifest *m2); int _list_cmp_toc_by_playorder(struct tocItem *t1, struct tocItem *t2); int _list_cmp_label_by_lang(struct tocLabel *t1, struct tocLabel *t2); void _list_dump_root(struct root *root); void _list_dump_string(char *string); void _list_dump_creator(struct creator *data); void _list_dump_date(struct date *date); void _list_dump_id(struct id *id); void _list_dump_meta(struct meta *meta); void _list_dump_spine(struct spine *spine); void _list_dump_guide(struct guide *guide); void _list_dump_tour(struct tour *tour); #endif /* epublib_h */ ebook-tools-0.2.2/src/libepub/epub.c0000644000530500000060000003233612021410400017037 0ustar elylevysystem#include "epub.h" #include "epublib.h" #include const char _epub_error_oom[] = "out of memory"; struct epub *epub_open(const char *filename, int debug) { char *opfName = NULL; char *opfStr = NULL; char *pathsep_index = NULL; struct epub *epub = malloc(sizeof(struct epub)); if (! epub) { return NULL; } epub->ocf = NULL; epub->opf = NULL; _epub_err_set_str(&epub->error, "", 0); epub->debug = debug; _epub_print_debug(epub, DEBUG_INFO, "opening '%s'", filename); LIBXML_TEST_VERSION; if (! (epub->ocf = _ocf_parse(epub, filename))) { epub_close(epub); return NULL; } opfName = _ocf_root_fullpath_by_type(epub->ocf, "application/oebps-package+xml"); if (!opfName) { epub_close(epub); return NULL; } epub->ocf->datapath = malloc(sizeof(char) *(strlen(opfName) +1)); pathsep_index = strrchr(opfName, '/'); // '/' is per OCF specs if (pathsep_index) { strncpy(epub->ocf->datapath, opfName, pathsep_index + 1 - opfName); epub->ocf->datapath[pathsep_index - opfName + 1] = 0; } else { epub->ocf->datapath[0] = 0; } _epub_print_debug(epub, DEBUG_INFO, "data path is %s", epub->ocf->datapath ); _ocf_get_file(epub->ocf, opfName, &opfStr); free(opfName); if (!opfStr) { epub_close(epub); return NULL; } epub->opf = _opf_parse(epub, opfStr); if (!epub->opf) { free(opfStr); epub_close(epub); return NULL; } free(opfStr); return epub; } xmlChar *_getXmlStr(void *str) { return xmlStrdup((xmlChar *)str); } xmlChar *_getIdStr(void *id) { struct id *data = (struct id *)id; xmlChar buff[10000]; xmlStrPrintf(buff, 10000, (xmlChar *)"%s (%s:%s)", ((data->scheme)?data->scheme:(xmlChar *)"Unspecified"), (data->id?data->id:(xmlChar *)"Unspecified"), data->string); return xmlStrdup(buff); } xmlChar *_getDateStr(void *date) { struct date *data = (struct date *)date; xmlChar buff[10000]; xmlStrPrintf(buff, 10000, (xmlChar *)"%s: %s", ((data->event)?data->event:(xmlChar *)"Unspecified"), data->date); return xmlStrdup(buff); } xmlChar *_getMetaStr(void *meta) { struct meta *data = (struct meta *)meta; xmlChar buff[10000]; xmlStrPrintf(buff, 10000, (xmlChar *)"%s: %s", ((data->name)?data->name:(xmlChar *)"Unspecified"), ((data->content)?data->content:(xmlChar *)"Unspecified")); return xmlStrdup(buff); } xmlChar *_getRoleStr(void *creator) { struct creator *data = (struct creator *)creator; xmlChar buff[10000]; xmlStrPrintf(buff, 10000, (xmlChar *)"%s: %s(%s)", ((data->role)?data->role:(xmlChar *)"Author"), data->name, ((data->fileAs)?data->fileAs:data->name)); return xmlStrdup(buff); } xmlChar **epub_get_metadata(struct epub *epub, enum epub_metadata type, int *size) { xmlChar **data = NULL; listPtr list = NULL; xmlChar *(*getStr)(void *) = NULL; int i; if (!epub || !epub->opf || !epub->opf->metadata) { _epub_print_debug(epub, DEBUG_INFO, "no metadata information available"); return NULL; } switch(type) { case EPUB_ID: list = epub->opf->metadata->id; getStr = _getIdStr; break; case EPUB_TITLE: list = epub->opf->metadata->title; getStr = _getXmlStr; break; case EPUB_SUBJECT: list = epub->opf->metadata->subject; getStr = _getXmlStr; break; case EPUB_PUBLISHER: list = epub->opf->metadata->publisher; getStr = _getXmlStr; break; case EPUB_DESCRIPTION: list = epub->opf->metadata->description; getStr = _getXmlStr; break; case EPUB_DATE: list = epub->opf->metadata->date; getStr = _getDateStr; break; case EPUB_TYPE: list = epub->opf->metadata->type; getStr = _getXmlStr; break; case EPUB_FORMAT: list = epub->opf->metadata->format; getStr = _getXmlStr; break; case EPUB_SOURCE: list = epub->opf->metadata->source; getStr = _getXmlStr; break; case EPUB_LANG: list = epub->opf->metadata->lang; getStr = _getXmlStr; break; case EPUB_RELATION: list = epub->opf->metadata->relation; getStr = _getXmlStr; break; case EPUB_COVERAGE: list = epub->opf->metadata->coverage; getStr = _getXmlStr; break; case EPUB_RIGHTS: list = epub->opf->metadata->rights; getStr = _getXmlStr; break; case EPUB_CREATOR: list = epub->opf->metadata->creator; getStr = _getRoleStr; break; case EPUB_CONTRIB: list = epub->opf->metadata->contrib; getStr = _getRoleStr; break; case EPUB_META: list = epub->opf->metadata->meta; getStr = _getMetaStr; break; default: _epub_print_debug(epub, DEBUG_INFO, "fetching metadata: unknown type %d", type); return NULL; } if (list->Size <= 0) return NULL; data = malloc(list->Size * sizeof(xmlChar *)); if (! data) { _epub_err_set_oom(&epub->error); return NULL; } if (size) { *size = list->Size; } list->Current = list->Head; data[0] = getStr(GetNode(list)); for (i=1;iSize;i++) { data[i] = getStr(NextNode(list)); } return data; } // returns the next node that the iterator should return // if init also check if the current node is good // if linear is 0 return non linear else return linear listnodePtr _get_spine_it_next(listnodePtr curr, int linear, int init) { struct spine *node; if (! curr) return NULL; if ( ! init) { curr = curr->Next; } node = (struct spine *)GetNodeData(curr); while(curr) { if (! node) return NULL; node = (struct spine *)GetNodeData(curr); if (node->linear == linear) return curr; curr = curr->Next; } return NULL; } char *_get_spine_it_url(struct eiterator *it) { struct manifest *tmp; void *data; if (!it) return NULL; data = GetNodeData(it->curr); tmp = _opf_manifest_get_by_id(it->epub->opf, ((struct spine *)data)->idref); if (!tmp) { _epub_print_debug(it->epub, DEBUG_ERROR, "spine parsing error idref %s is not in the manifest", ((struct spine *)data)->idref); return NULL; } return (char *)tmp->href; } struct eiterator *epub_get_iterator(struct epub *epub, enum eiterator_type type, int opt) { struct eiterator *it = NULL; if (!epub) { return NULL; } it = malloc(sizeof(struct eiterator)); if (!it) { _epub_err_set_oom(&epub->error); return NULL; } it->type = type; it->epub = epub; it->opt = opt; it->cache = NULL; switch (type) { case EITERATOR_SPINE: it->curr = epub->opf->spine->Head; break; case EITERATOR_NONLINEAR: it->curr = _get_spine_it_next(epub->opf->spine->Head, 0, 1); break; case EITERATOR_LINEAR: it->curr = _get_spine_it_next(epub->opf->spine->Head, 1, 1); break; } return it; } void epub_free_iterator(struct eiterator *it) { if (!it) { return; } if (it->cache) free(it->cache); free(it); } char *epub_it_get_curr_url(struct eiterator *it) { if (!it) { return NULL; } switch (it->type) { case EITERATOR_SPINE: case EITERATOR_NONLINEAR: case EITERATOR_LINEAR: return _get_spine_it_url(it); } return NULL; } char *epub_it_get_curr(struct eiterator *it) { if (!it || !it->curr) return NULL; if (!it->cache) { switch (it->type) { case EITERATOR_SPINE: case EITERATOR_NONLINEAR: case EITERATOR_LINEAR: _ocf_get_data_file(it->epub->ocf, _get_spine_it_url(it), &(it->cache)); break; } } return it->cache; } char *epub_it_get_next(struct eiterator *it) { if (!it) { return NULL; } if (it->cache) { free(it->cache); it->cache = NULL; } if (!it->curr) return NULL; switch (it->type) { case EITERATOR_SPINE: it->curr = it->curr->Next; break; case EITERATOR_NONLINEAR: it->curr = _get_spine_it_next(it->curr, 0, 0); break; case EITERATOR_LINEAR: it->curr = _get_spine_it_next(it->curr, 1, 0); break; } return epub_it_get_curr(it); } int epub_close(struct epub *epub) { if (!epub) { return 0; } if (epub->ocf) _ocf_close(epub->ocf); if (epub->opf) _opf_close(epub->opf); if (epub) free(epub); return 1; } void epub_set_debug(struct epub *epub, int debug) { if (!epub) { return; } epub->debug = debug; } void _epub_print_debug(struct epub *epub, int debug, const char *format, ...) { va_list ap; char strerr[1025]; va_start(ap, format); vsnprintf(strerr, 1024, format, ap); strerr[1024] = 0; if (epub && (debug == DEBUG_ERROR)) { _epub_err_set_str(&epub->error, strerr, strlen(strerr)); } if (! epub || (epub->debug >= debug)) { fprintf(stderr, "libepub "); switch(debug) { case DEBUG_ERROR: fprintf(stderr, "(EE)"); break; case DEBUG_WARNING: fprintf(stderr, "(WW)"); break; case DEBUG_INFO: fprintf(stderr, "(II)"); break; case DEBUG_VERBOSE: fprintf(stderr, "(VV)"); break; } fprintf(stderr, ": \t%s\n" , strerr); } va_end(ap); } int epub_tit_next(struct titerator *tit) { listnodePtr curr = NULL; if (!tit) { return 0; } curr = tit->next; if (! curr) { tit->valid = 0; return 0; } tit->next = curr->Next; switch (tit->type) { struct guide* guide; struct tocItem *ti; case TITERATOR_GUIDE: guide = GetNodeData(curr); tit->cache.label = (char *)guide->title; tit->cache.link = (char *)guide->href; tit->cache.depth = 1; break; case TITERATOR_NAVMAP: case TITERATOR_PAGES: ti = GetNodeData(curr); tit->cache.label = (char *)_opf_label_get_by_doc_lang(tit->epub->opf, ti->label); if (! tit->cache.label) tit->cache.label = (char *)ti->id; tit->cache.depth = ti->depth; tit->cache.link = (char *)ti->src; break; } tit->valid = 1; return 1; } struct titerator *epub_get_titerator(struct epub *epub, enum titerator_type type, int opt) { struct titerator *it = NULL; if (!epub) { return NULL; } switch (type) { case TITERATOR_NAVMAP: if (! epub->opf->toc || ! epub->opf->toc->navMap) return NULL; break; case TITERATOR_GUIDE: if (! epub->opf->guide) return NULL; break; case TITERATOR_PAGES: if (! epub->opf->toc || epub->opf->toc->pageList) return NULL; break; } it = malloc(sizeof(struct titerator)); if (!it) { _epub_err_set_oom(&epub->error); return NULL; } it->type = type; it->epub = epub; it->opt = opt; it->next = NULL; it->valid = 0; it->cache.label = NULL; it->cache.link = NULL; it->cache.depth = -1; switch (type) { case TITERATOR_NAVMAP: it->next = epub->opf->toc->navMap->items->Head; if (epub->opf->toc->navMap->label) { it->cache.label = (char *)_opf_label_get_by_doc_lang(epub->opf, epub->opf->toc->navMap->label); it->cache.depth = 0; } it->valid = 1; break; case TITERATOR_GUIDE: it->next = epub->opf->guide->Head; break; case TITERATOR_PAGES: it->next = epub->opf->toc->pageList->items->Head; if (epub->opf->toc->pageList->label) { it->cache.label = (char *)_opf_label_get_by_doc_lang(epub->opf, epub->opf->toc->pageList->label); it->cache.depth = 1; } it->valid = 1; break; } if ( ! it->cache.label) epub_tit_next(it); return it; } int epub_tit_curr_valid(struct titerator *tit) { if (!tit) { return 0; } return tit->valid; } char *epub_tit_get_curr_label(struct titerator *tit) { if (!tit) { return NULL; } // FIXME how can there be unlabeled curr? return tit->cache.label?strdup(tit->cache.label):NULL; } int epub_tit_get_curr_depth(struct titerator *tit) { if (!tit) { return 0; } return tit->cache.depth; } char *epub_tit_get_curr_link(struct titerator *tit) { if (!tit) { return NULL; } if (!tit->cache.link) { return NULL; } return strdup(tit->cache.link); } void epub_free_titerator(struct titerator *tit) { if (!tit) { return; } free(tit); } int epub_get_ocf_file(struct epub *epub, const char *filename, char **data) { if (!epub) { return -1; } return _ocf_get_file(epub->ocf, filename, data); } int epub_get_data(struct epub *epub, const char *name, char **data) { if (!epub) { return -1; } return _ocf_get_data_file(epub->ocf, name, data); } void epub_dump(struct epub *epub) { if (!epub) { return; } _ocf_dump(epub->ocf); _opf_dump(epub->opf); } void epub_cleanup() { xmlCleanupParser(); } char *epub_last_errStr(struct epub *epub) { char *res = NULL; if (!epub) { return NULL; } switch (epub->error.type) { case 0: res = malloc(epub->error.len + 1); if (!res) { _epub_err_set_oom(&epub->error); return NULL; } strncpy(res, epub->error.lastStr, epub->error.len); res[epub->error.len] = 0; break; case 1: res = strdup(epub->error.str); if (!res) { _epub_err_set_oom(&epub->error); return NULL; } break; } return res; } ebook-tools-0.2.2/src/libepub/linklist.c0000644000530500000060000005105312021410400017732 0ustar elylevysystem/* LinkList.C -- ANSI C Linked List Container Type Handles Lists, Queues, Stacks, Splay trees, and custom list types via one consistant interface. - Written by Jeff Hay, jrhay@lanl.gov */ #include "linklist.h" #include listPtr NewListAlloc(int ListType, ListAlloc Lalloc, ListFreeFunc Lfree, NodeCompareFunc Cfunc) { listPtr List; if (Lalloc == NULL) Lalloc = malloc; if (Lfree == NULL) Lfree = free; if ((List = (listPtr)((Lalloc)(sizeof(struct LList)))) != NULL) { List->Current = List->Head = List->Tail = NULL; List->memalloc = Lalloc; List->memfree = Lfree; List->compare = Cfunc; List->Size = 0; List->Flags = ListType; } return List; } /* NewListAlloc() */ listnodePtr NewListNode(listPtr List, void *Data) { listnodePtr Node; ListAlloc Alloc; if (List == NULL) Alloc = malloc; else Alloc = List->memalloc; if ((Node = (listnodePtr)((Alloc(sizeof(struct ListNode))))) != NULL) { Node->Data = Data; Node->Next = Node->Prev = NULL; } return Node; } /* NewListNode() */ void *GetNode(listPtr List) { void *Data; int Delete; if (List == NULL) return NULL; Data = NULL; Delete = ((List->Flags & LISTFLAGMASK) & LISTDELREAD); switch (List->Flags & LISTREADMASK) { case LISTREADHEAD: if (List->Head != NULL) { Data = List->Head->Data; if (Delete) DelHeadList(List); } break; case LISTREADTAIL: if (List->Tail != NULL) { Data = List->Tail->Data; if (Delete) DelTailList(List); } break; default: case LISTREADCURR: if (List->Current != NULL) { Data = List->Current->Data; if (Delete) RemoveList(List); } break; } return Data; } /* GetNode() */ void *GetNodeData(listnodePtr Node) { if (Node != NULL) return Node->Data; else return NULL; } /* GetNodeData() */ void *FindNode(listPtr List, void *Data) { int Compare; if ((List == NULL) || (List->compare == NULL)) return NULL; if ((List->Flags & LISTADDMASK) & LISTADDSPLAY) { /* List is a splay tree; do weirdness... */ if (SplayList(List, Data) != NULL) Compare = 0; } if ((List->Flags & LISTFLAGMASK) & LISTBTREE) { /* List is some other binary tree, do a binary tree search... */ if (BTFind(List, Data) != NULL) Compare = 0; } else { /* List is a normal list, not a tree, step through it... */ List->Current = List->Head; if (List->Current == NULL) return NULL; while ((Compare = (List->compare)(List->Current->Data, Data)) != 0) { List->Current = List->Current->Next; if (List->Current == NULL) return NULL; // end of list } } if (Compare != 0) return NULL; else return List->Current->Data; } /* FindNode() */ void *BTFind(listPtr List, void *Data) { int Compare; if ((List == NULL) || (List->compare == NULL)) return NULL; Compare = 1; while ((Compare != 0) && (List->Current != NULL)) { if ((Compare = (List->compare)(List->Current->Data, Data) != 0)) { if (Compare < 0) List->Current = List->Current->Next; else List->Current = List->Current->Prev; } } if (List->Current != NULL) return List->Current->Data; else return NULL; } /* BTFind() */ int AddNode(listPtr List, listnodePtr Node) { if (List == NULL) return LLIST_NULL; switch (List->Flags & LISTADDMASK) { case LISTADDCURR: return InsertList(List, Node); break; case LISTADDHEAD: return HeadList(List, Node); break; case LISTADDTAIL: return TailList(List, Node); break; case LISTADDSPLAY: return SplayInsertList(List, Node); break; default: return InsertList(List, Node); break; } return LLIST_ERROR; } /* AddNode() */ int SplayInsertList(listPtr List, listnodePtr Node) { if (List == NULL) return LLIST_NULL; if (Node == NULL) return LLIST_NULL; if (List->Head != NULL) /* empty tree? */ { if (SplayList(List, Node->Data) != NULL) /* We found this element in the splay tree; this is bad. Say so... */ return LLIST_BADVALUE; if ((List->compare)(Node->Data, List->Head->Data) > 0) { Node->Prev = List->Head; if ((List->compare)(Node->Data, GetNodeData(List->Head->Next)) < 0) { Node->Next = List->Head->Next; List->Head->Next = NULL; } } else { Node->Next = List->Head; if ((List->compare)(Node->Data, GetNodeData(List->Head->Prev)) > 0) { Node->Prev = List->Head->Prev; List->Head->Prev = NULL; } } } List->Head = List->Current = Node; List->Size++; return LLIST_NOERROR; } /* SplayInsertList() */ int InsertList(listPtr List, listnodePtr Node) { if (List == NULL) return LLIST_NULL; if (Node == NULL) return LLIST_NULL; if (List->Current != NULL) { Node->Prev = List->Current; Node->Next = List->Current->Next; List->Current->Next = Node; if (Node->Next == NULL) List->Tail = Node; else Node->Next->Prev = Node; } List->Current = Node; if (++List->Size == 1) /* If List Was Empty... */ { List->Head = Node; List->Tail = Node; } return LLIST_NOERROR; } /* InsertList() */ int HeadList(listPtr List, listnodePtr Node) { if (List == NULL) return LLIST_NULL; if (Node == NULL) return LLIST_NULL; if (List->Head != NULL) { Node->Next = List->Head; List->Head->Prev = Node; } List->Head = Node; List->Current = Node; if (++List->Size == 1) /* If List Was Empty... */ List->Tail = Node; return LLIST_NOERROR; } /* HeadList() */ int TailList(listPtr List, listnodePtr Node) { if (List == NULL) return LLIST_NULL; if (Node == NULL) return LLIST_NULL; if (List->Tail != NULL) { Node->Prev = List->Tail; List->Tail->Next = Node; } List->Tail = Node; List->Current = Node; if (++List->Size == 1) /* If List Was Empty... */ List->Head = Node; return LLIST_NOERROR; } /* TailList() */ int SplayRemoveList(listPtr List) { listnodePtr _DelNode; if (List == NULL) return LLIST_NULL; if (List->Head == NULL) return LLIST_NOERROR; /* Assumes List->Head (root of splay tree) is already selected to be deleted node */ _DelNode = List->Head; if (List->Head->Next == NULL) List->Head = List->Head->Prev; else { if (List->Head->Prev != NULL) { SplayList(List, List->Head->Prev->Data); /* Must succeed */ List->Head->Next = _DelNode->Next; } else List->Head = List->Head->Next; } List->memfree(_DelNode); List->Current = List->Head; List->Size--; return LLIST_NOERROR; } /* SplayRemoveList() */ int DelNode(listPtr List) { if (List == NULL) return LLIST_NULL; switch (List->Flags & LISTDELMASK) { case LISTDELCURR: return RemoveList(List); break; case LISTDELHEAD: return DelHeadList(List); break; case LISTDELTAIL: return DelTailList(List); break; case LISTDELSPLAY: return SplayRemoveList(List); break; default: return RemoveList(List); break; } return LLIST_ERROR; } /* DelNode() */ int RemoveList(listPtr List) { listnodePtr Temp; if (List == NULL) return LLIST_NULL; if (List->Current == NULL) return LLIST_NOERROR; if (List->Current == List->Head) return DelHeadList(List); if (List->Current == List->Tail) return DelTailList(List); Temp = List->Current; Temp->Prev->Next = List->Current->Next; Temp->Next->Prev = List->Current->Prev; List->Current = List->Current->Next; List->memfree(Temp); List->Size--; return LLIST_NOERROR; } /* RemoveList() */ int DelHeadList(listPtr List) { listnodePtr Temp; if (List == NULL) return LLIST_NULL; if (List->Head == NULL) return LLIST_NOERROR; Temp = List->Head; if (Temp->Next != NULL) Temp->Next->Prev = NULL; List->Head = Temp->Next; List->Current = List->Head; List->memfree(Temp); List->Size--; return LLIST_NOERROR; } /* DelHeadList() */ int DelTailList(listPtr List) { listnodePtr Temp; if (List == NULL) return LLIST_NULL; if (List->Tail == NULL) return LLIST_NOERROR; Temp = List->Tail; if (Temp->Prev != NULL) Temp->Prev->Next = NULL; List->Tail = Temp->Prev; List->Current = List->Tail; List->memfree(Temp); List->Size--; return LLIST_NOERROR; } /* DelTailList() */ void *NextNode(listPtr List) { if (List == NULL) return NULL; if (List->Current != NULL) List->Current = List->Current->Next; if ((List->Flags & LISTFLAGMASK) & LISTCIRCULAR) if (List->Current == NULL) List->Current = List->Head; return GetNodeData(List->Current); } /* NextNode() */ void *PrevNode(listPtr List) { if (List == NULL) return NULL; if (List->Current != NULL) List->Current = List->Current->Prev; if ((List->Flags & LISTFLAGMASK) & LISTCIRCULAR) if (List->Current == NULL) List->Current = List->Tail; return GetNodeData(List->Current); } /* PrevNode() */ void *IndexNode(listPtr List, int Index) { int Count; if ((List == NULL) || ((List->Flags & LISTFLAGMASK) & LISTBTREE)) return NULL; if (List->Size < Index) return NULL; List->Current = List->Head; for (Count = 1; Count < Index; Count++) List->Current = List->Current->Next; return GetNodeData(List->Current); } /* IndexNode() */ int FreeList(listPtr List, ListFreeFunc DataFree) { int Delete; if (List == NULL) return LLIST_NULL; List->Current = List->Head; Delete = LLIST_NOERROR; while ((Delete == LLIST_NOERROR) && (List->Size > 0)) { if ((DataFree != NULL) && (List->Head->Data != NULL)) DataFree(List->Head->Data); if ((List->Flags & LISTDELMASK) & LISTDELSPLAY) Delete = SplayRemoveList(List); else Delete = DelHeadList(List); } if (Delete == LLIST_NOERROR) List->memfree(List); return Delete; } /* FreeList() */ void SwapList(listPtr List) { listnodePtr Temp1, Temp2; if ((List == NULL) || (List->Current == NULL) || (List->Current->Next == NULL)) return; Temp1 = List->Current; Temp2 = List->Current->Next; Temp1->Next = Temp2->Next; if (Temp2->Next != NULL) Temp2->Next->Prev = Temp1; else List->Tail = Temp1; Temp2->Prev = Temp1->Prev; if (Temp1->Prev != NULL) Temp1->Prev->Next = Temp2; else List->Head = Temp2; Temp1->Prev = Temp2; Temp2->Next = Temp1; return; } /* SwapList() */ void SortList(listPtr List) { int Move; if ((List == NULL) || (List->compare == NULL) || ((List->Flags & LISTFLAGMASK) & LISTBTREE)) return; /* This is a DA-sort!! */ if (List->Head == NULL) return; Move = 1; while (Move != 0) { Move = 0; List->Current = List->Head; while (List->Current->Next != NULL) { if ((List->compare)(List->Current->Data, List->Current->Next->Data) > 0) { Move++; SwapList(List); }; if (List->Current->Next != NULL) List->Current = List->Current->Next; } } List->Current = List->Head; return; } /* SortList() */ void *SplayList(listPtr List, void *Data) { listnodePtr Temp, Left, Right, LeftRoot, RightRoot; int Test; if ((List == NULL) || (List->compare == NULL)) return NULL; /* Implements a top-down splay on the list; that is, it splays as it searches down the list for Data. (Basic algorithm from Sleator and Tarjan's "Self-Adjusting Binary Search Trees" paper of 1985) */ List->Current = List->Head; if (List->Current == NULL) return NULL; Left = LeftRoot = Right = RightRoot = NULL; for (;;) { if ((Test = (List->compare)(Data, List->Current->Data)) < 0) { if (List->Current->Prev == NULL) break; if ((List->compare)(Data, List->Current->Prev->Data) < 0) { Temp = List->Current->Prev; List->Current->Prev = Temp->Next; Temp->Next = List->Current; List->Current = Temp; if (List->Current->Prev == NULL) break; } if (Right == NULL) Right = RightRoot = List->Current; else { Right->Prev = List->Current; Right = List->Current; } List->Current = List->Current->Prev; } else if (Test > 0) { if (List->Current->Next == NULL) break; if ((List->compare)(Data, List->Current->Next->Data) > 0) { Temp = List->Current->Next; List->Current->Next = Temp->Prev; Temp->Prev = List->Current; List->Current = Temp; if (List->Current->Next == NULL) break; } if (Left == NULL) Left = LeftRoot = List->Current; else { Left->Next = List->Current; Left = List->Current; } List->Current = List->Current->Next; } else break; } if (List->Current == NULL) return NULL; if (Left != NULL) Left->Next = List->Current->Prev; else LeftRoot = List->Current->Prev; if (Right != NULL) Right->Prev = List->Current->Next; else RightRoot = List->Current->Next; /* This assignment order is backwards from example code, but seems to work... (and makes more intuitive sense) */ List->Current->Next = RightRoot; List->Current->Prev = LeftRoot; List->Head = List->Current; if ((List->compare)(Data, List->Head->Data) == 0) return List->Head; else return NULL; } /* SplayList() */ int StringCompare(char *First, char* Second) { /* printf("comparing \"%s\" to \"%s\"\n", First, Second); */ if ((First != NULL) && (Second != NULL)) return strcmp(First, Second); else return 0; } /* StringCompare() */ int IntCompare(int *First, int* Second) { if ((First == NULL) || (Second == NULL)) return 0; if (*First > *Second) return 1; if (*First < *Second) return -1; return 0; } /* IntCompare() */ int DoubleCompare(double *First, double* Second) { if ((First == NULL) || (Second == NULL)) return 0; if (*First > *Second) return 1; if (*First < *Second) return -1; return 0; } /* DoubleCompare() */ /* End of LinkList Library - Remainder of code is for the demonstration/test routines */ int DumpList(listPtr List, ListDumpFunc DataDump) /* Print List data using the DataDump function for Node Data Elements */ { int Count; listnodePtr Position; if (List == NULL) return LLIST_BADVALUE; Position = List->Current; List->Current = List->Head; for (Count = 1; Count <= List->Size; Count++) { DataDump(GetNodeData(List->Current)); NextNode(List); } List->Current = Position; return LLIST_NOERROR; } #ifdef LINKLIST_TEST #include /* for strcmp() comparison procedure */ int PrintList(listPtr List, char *DataFmt) /* Print List using DataFmt as the printf() format for Node Data Elements */ { int Count; listnodePtr Position; char OutStr[30]; if (List == NULL) return LLIST_BADVALUE; if (List->Flags & LISTBTREE) return PrintTree(List, DataFmt); strcpy(OutStr, "\tHead: "); strcat(OutStr, DataFmt); strcat(OutStr, "\tTail: "); strcat(OutStr, DataFmt); strcat(OutStr, "\n"); printf(OutStr, GetNodeData(List->Head), GetNodeData(List->Tail)); strcpy(OutStr, "Index: %d\tData: "); strcat(OutStr, DataFmt); strcat(OutStr, "\n"); Position = List->Current; List->Current = List->Head; for (Count = 1; Count <= List->Size; Count++) { printf(OutStr, Count, GetNodeData(List->Current)); NextNode(List); } List->Current = Position; return LLIST_NOERROR; } /* PrintList */ void GraphicTree(listnodePtr Node, char *DataFmt, int Level) /* Recursive procedure to print the structure of a binary tree. From example code by Matthew Weathers at Biola University */ { int Count; char OutStr[30]; if (Node != NULL) { for (Count = 0; Count < Level; Count++) printf("\t"); strcpy(OutStr, "\""); strcat(OutStr, DataFmt); strcat(OutStr, "\" (left=\""); strcat(OutStr, DataFmt); strcat(OutStr, "\", right=\""); strcat(OutStr, DataFmt); strcat(OutStr, "\")\n"); printf(OutStr, GetNodeData(Node), GetNodeData(Node->Prev), GetNodeData(Node->Next)); GraphicTree(Node->Prev, DataFmt, Level + 1); GraphicTree(Node->Next, DataFmt, Level + 1); } } int PrintTree(listPtr List, char *DataFmt) { listnodePtr Parent; if (List == NULL) return LLIST_BADVALUE; printf("\nTree: (%d Nodes)\n", List->Size); GraphicTree(List->Head, DataFmt, 0); printf("\n"); return LLIST_NOERROR; } /* PrintTree */ /* --- End of simple debugging malloc wrappers --- */ int main() { listPtr List, Queue, Stack, Splay; char *String1, *String2, *String3, *String4, *Get; int Result; printf("Testing LINKLIST Library for ANSI C.\n\n"); String1 = malloc(20); String2 = malloc(20); String3 = malloc(20); String4 = malloc(20); strcpy(String1, "Hi"); strcpy(String2, "Low"); strcpy(String3, "Up"); strcpy(String4, "Down"); printf("Creating List.\n"); List = NewListAlloc(LIST, DMALLOC, DFREE, (NodeCompareFunc)strcmp); printf("Creating Queue.\n"); Queue = NewListAlloc(QUEUE, DMALLOC, DFREE, NULL); printf("Creating Stack.\n"); Stack = NewListAlloc(STACK, DMALLOC, DFREE, NULL); printf("Creating Splay Tree\n"); Splay = NewListAlloc(STREE, DMALLOC, DFREE, (NodeCompareFunc)StringCompare); printf("Adding Elements to List...\n"); AddNode(List, NewNode("Hi")); AddNode(List, NewNode("Low")); AddNode(List, NewNode("Up")); AddNode(List, NewNode("Down")); printf("Adding Elements to Queue...\n"); AddNode(Queue, NewNode("Hi")); AddNode(Queue, NewNode("Low")); AddNode(Queue, NewNode("Up")); AddNode(Queue, NewNode("Down")); printf("Adding Elements to Stack...\n"); AddNode(Stack, NewNode(String1)); AddNode(Stack, NewNode(String2)); AddNode(Stack, NewNode(String3)); AddNode(Stack, NewNode(String4)); printf("Adding Elements to Splay Tree...\n"); AddNode(Splay, NewNode("High")); AddNode(Splay, NewNode("Low")); AddNode(Splay, NewNode("Up")); AddNode(Splay, NewNode("Down")); printf("Attempting to add duplicate nodes to Splay Tree...\n"); Result = AddNode(Splay, NewNode("Down")); printf("Result: "); if (Result == LLIST_OK) printf("OK\n"); else if (Result == LLIST_BADVALUE) printf("Node Already Exists; not added\n"); else printf("Error\n"); printf("Calimed Memory: %d bytes\n", DCOUNT(NULL)); printf("LIST:\n"); PrintList(List, "%s"); printf("QUEUE:\n"); PrintList(Queue, "%s"); printf("STACK:\n"); PrintList(Stack, "%s"); printf("SPLAY:\n"); PrintList(Splay, "%s"); printf("\n-----------------------\n"); printf("Reading Element from LIST\n"); printf("Read Element: %s\n", GetNode(List)); PrintList(List, "%s"); printf("\n\nReading Element from QUEUE\n"); printf("Read Element: %s\n", GetNode(Queue)); PrintList(Queue, "%s"); printf("\n\nReading Element from STACK\n"); printf("Read Element: %s\n", (Get = GetNode(Stack))); DFREE(Get); PrintList(Stack, "%s"); printf("\n-----------------------\n"); printf("Reading Element #2 from LIST\n"); printf("Read Element: %s\n", IndexNode(List, 2)); PrintList(List, "%s"); printf("\nAdding One More Element to LIST\n"); AddNode(List, NewNode("And")); PrintList(List, "%s"); printf("\n-----------------------\n"); printf("\nSorting LIST\n"); SortList(List); PrintList(List, "%s"); printf("\n-----------------------\n"); printf("\nDeleting Element 2 From LIST\n"); IndexNode(List, 2); RemoveList(List); PrintList(List, "%s"); printf("\nDeleting Head From LIST\n"); DelHeadList(List); PrintList(List, "%s"); printf("\nDeleting Tail From LIST\n"); DelTailList(List); PrintList(List, "%s"); printf("\n------------------------\n"); printf("Reading Element from Splay Tree\n"); printf("Read Element: %s\n", GetNode(Splay)); printf("\nDeleting Element From Splay Tree\n"); DelNode(Splay); PrintList(Splay, "%s"); printf("\nDeleting Element \"Low\" In Splay Tree\n"); FindNode(Splay, "Low"); DelNode(Splay); PrintList(Splay, "%s"); printf("Reading Element from Splay Tree\n"); printf("Read Element: %s\n", GetNode(Splay)); printf("\n-----------------------\n"); printf("Removing List.\n"); FreeList(List, NULL); printf("Removing Queue.\n"); FreeList(Queue, NULL); printf("Removing Stack.\n"); FreeList(Stack, NULL); printf("Removing Splay Tree.\n"); FreeList(Splay, NULL); printf("\n-----------------------\n"); printf("\nUnclaimed Memory: %d bytes\n", DCOUNT(NULL)); printf("\nLinkList Test/Demo Done.\n"); return 0; } /* main */ #endif /* LINKLIST_TEST */ ebook-tools-0.2.2/src/libepub/CMakeLists.txt0000644000530500000060000000076512021410400020501 0ustar elylevysysteminclude_directories (${EBOOK-TOOLS_SOURCE_DIR}/src/libepub ${LIBXML2_INCLUDE_DIR} ${LIBZIP_INCLUDE_DIR}) add_library (epub SHARED epub.c ocf.c opf.c linklist.c list.c) target_link_libraries (epub ${LIBZIP_LIBRARY} ${LIBXML2_LIBRARIES}) set_target_properties (epub PROPERTIES VERSION 0.2.1 SOVERSION 0) install ( TARGETS epub RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} ) install ( FILES epub.h epub_shared.h epub_version.h DESTINATION include ) ebook-tools-0.2.2/src/libepub/epub_version.h0000644000530500000060000000073612021410400020610 0ustar elylevysystem#ifndef _LIBEPUB_VERSION_H_ #define _LIBEPUB_VERSION_H_ #define LIBEPUB_VERSION_STRING "0.2.1" #define LIBEPUB_VERSION_MAJOR 0 #define LIBEPUB_VERSION_MINOR 2 #define LIBEPUB_VERSION_RELEASE 1 #define LIBEPUB_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c)) #define LIBEPUB_VERSION \ LIBEPUB_MAKE_VERSION(LIBEPUB_VERSION_MAJOR,LIBEPUB_VERSION_MINOR,LIBEPUB_VERSION_RELEASE) #define LIBEPUB_IS_VERSION(a,b,c) ( LIBEPUB_VERSION >= LIBEPUB_MAKE_VERSION(a,b,c) ) #endif ebook-tools-0.2.2/src/libepub/opf.c0000644000530500000060000007725312021410400016677 0ustar elylevysystem#include "epublib.h" struct opf *_opf_parse(struct epub *epub, char *opfStr) { struct opf *opf; xmlTextReaderPtr reader; int ret; _epub_print_debug(epub, DEBUG_INFO, "building opf struct"); opf = malloc(sizeof(struct opf)); if (!opf) { _epub_err_set_oom(&epub->error); return NULL; } memset(opf, 0, sizeof(struct opf)); opf->epub = epub; reader = xmlReaderForMemory(opfStr, strlen(opfStr), "OPF", NULL, 0); if (reader != NULL) { ret = xmlTextReaderRead(reader); while (ret == 1) { const xmlChar *name = xmlTextReaderConstLocalName(reader); if (xmlStrcmp(name, (xmlChar *)"metadata") == 0) _opf_parse_metadata(opf, reader); else if (xmlStrcmp(name, (xmlChar *)"manifest") == 0) _opf_parse_manifest(opf, reader); else if (xmlStrcmp(name, (xmlChar *)"spine") == 0) _opf_parse_spine(opf, reader); else if (xmlStrcmp(name, (xmlChar *)"guide") == 0) _opf_parse_guide(opf, reader); else if (xmlStrcmp(name, (xmlChar *)"tours") == 0) _opf_parse_tours(opf, reader); ret = xmlTextReaderRead(reader); } xmlFreeTextReader(reader); if (ret != 0) { _epub_print_debug(opf->epub, DEBUG_ERROR, "failed to parse OPF"); return NULL; } else if(!opf->spine) { _epub_print_debug(opf->epub, DEBUG_ERROR, "Ilegal OPF no spine found"); return NULL; } } else { _epub_print_debug(opf->epub, DEBUG_ERROR, "unable to open OPF"); return NULL; } return opf; } xmlChar *_get_possible_namespace(xmlTextReaderPtr reader, const xmlChar * localName, const xmlChar * namespace) { xmlChar *tmp, *ns; ns = xmlTextReaderLookupNamespace(reader, namespace); tmp = xmlTextReaderGetAttributeNs(reader, localName, ns); if (ns) free(ns); if (! tmp) return xmlTextReaderGetAttribute(reader, localName); return tmp; } void _opf_init_metadata(struct opf *opf) { struct metadata *meta = malloc(sizeof(struct metadata)); meta->id = NewListAlloc(LIST, NULL, NULL, NULL); meta->title = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->creator = NewListAlloc(LIST, NULL, NULL, NULL); meta->contrib = NewListAlloc(LIST, NULL, NULL, NULL); meta->subject = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->publisher = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->description = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->date = NewListAlloc(LIST, NULL, NULL, NULL); meta->type = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->format = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->source = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->lang = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->relation = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->coverage = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->rights = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)StringCompare); meta->meta = NewListAlloc(LIST, NULL, NULL, NULL); opf->metadata = meta; } void _opf_free_metadata(struct metadata *meta) { FreeList(meta->id, (ListFreeFunc)_list_free_id); FreeList(meta->title, free); FreeList(meta->creator, (ListFreeFunc)_list_free_creator); FreeList(meta->contrib, (ListFreeFunc)_list_free_creator); FreeList(meta->subject, free); FreeList(meta->publisher, free); FreeList(meta->description, free); FreeList(meta->date, (ListFreeFunc)_list_free_date); FreeList(meta->type, free); FreeList(meta->format, free); FreeList(meta->source, free); FreeList(meta->lang, free); FreeList(meta->relation, free); FreeList(meta->coverage, free); FreeList(meta->rights, free); FreeList(meta->meta, (ListFreeFunc)_list_free_meta); free(meta); } void _opf_parse_metadata(struct opf *opf, xmlTextReaderPtr reader) { int ret; struct metadata *meta; const xmlChar *local; xmlChar *string; _epub_print_debug(opf->epub, DEBUG_INFO, "parsing metadata"); // must have title, identifier and language _opf_init_metadata(opf); meta = opf->metadata; ret = xmlTextReaderRead(reader); while (ret == 1 && xmlStrcasecmp(xmlTextReaderConstLocalName(reader),(xmlChar *)"metadata")) { // ignore non starting tags if (xmlTextReaderNodeType(reader) != 1) { ret = xmlTextReaderRead(reader); continue; } local = xmlTextReaderConstLocalName(reader); string = (xmlChar *)xmlTextReaderReadString(reader); if (xmlStrcasecmp(local, (xmlChar *)"identifier") == 0) { struct id *new = malloc(sizeof(struct id)); new->string = string; new->scheme = _get_possible_namespace(reader, (xmlChar *)"scheme", (xmlChar *)"opf"); new->id = xmlTextReaderGetAttribute(reader, (xmlChar *)"id"); AddNode(meta->id, NewListNode(meta->id, new)); _epub_print_debug(opf->epub, DEBUG_INFO, "identifier %s(%s) is: %s", new->id, new->scheme, new->string); } else if (xmlStrcasecmp(local, (xmlChar *)"title") == 0) { AddNode(meta->title, NewListNode(meta->title, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "title is %s", string); } else if (xmlStrcasecmp(local, (xmlChar *)"creator") == 0) { struct creator *new = malloc(sizeof(struct creator)); new->name = string; new->fileAs = _get_possible_namespace(reader, (xmlChar *)"file-as", (xmlChar *)"opf"); new->role = _get_possible_namespace(reader, (xmlChar *)"role", (xmlChar *)"opf"); AddNode(meta->creator, NewListNode(meta->creator, new)); _epub_print_debug(opf->epub, DEBUG_INFO, "creator - %s: %s (%s)", new->role, new->name, new->fileAs); } else if (xmlStrcasecmp(local, (xmlChar *)"contributor") == 0) { struct creator *new = malloc(sizeof(struct creator)); new->name = string; new->fileAs = _get_possible_namespace(reader, (xmlChar *)"file-as", (xmlChar *)"opf"); new->role = _get_possible_namespace(reader, (xmlChar *)"role", (xmlChar *)"opf"); AddNode(meta->contrib, NewListNode(meta->contrib, new)); _epub_print_debug(opf->epub, DEBUG_INFO, "contributor - %s: %s (%s)", new->role, new->name, new->fileAs); } else if (xmlStrcasecmp(local, (xmlChar *)"meta") == 0) { struct meta *new = malloc(sizeof(struct meta)); new->name = xmlTextReaderGetAttribute(reader, (xmlChar *)"name"); new->content = xmlTextReaderGetAttribute(reader, (xmlChar *)"content"); AddNode(meta->meta, NewListNode(meta->meta, new)); if (string) free(string); _epub_print_debug(opf->epub, DEBUG_INFO, "meta is %s: %s", new->name, new->content); } else if (xmlStrcasecmp(local, (xmlChar *)"date") == 0) { struct date *new = malloc(sizeof(struct date)); new->date = string; new->event = _get_possible_namespace(reader, (xmlChar *)"event", (xmlChar *)"opf"); AddNode(meta->date, NewListNode(meta->date, new)); _epub_print_debug(opf->epub, DEBUG_INFO, "date of %s: %s", new->event, new->date); } else if (xmlStrcasecmp(local, (xmlChar *)"subject") == 0) { AddNode(meta->subject, NewListNode(meta->subject, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "subject is %s", string); } else if (xmlStrcasecmp(local, (xmlChar *)"publisher") == 0) { AddNode(meta->publisher, NewListNode(meta->publisher, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "publisher is %s", string); } else if (xmlStrcasecmp(local, (xmlChar *)"description") == 0) { AddNode(meta->description, NewListNode(meta->description, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "description is %s", string); } else if (xmlStrcasecmp(local, (xmlChar *)"type") == 0) { AddNode(meta->type, NewListNode(meta->type, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "type is %s", string); } else if (xmlStrcasecmp(local, (xmlChar *)"format") == 0) { AddNode(meta->format, NewListNode(meta->format, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "format is %s", string); } else if (xmlStrcasecmp(local, (xmlChar *)"source") == 0) { AddNode(meta->source, NewListNode(meta->source, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "source is %s", string); } else if (xmlStrcasecmp(local, (xmlChar *)"language") == 0) { AddNode(meta->lang, NewListNode(meta->lang, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "language is %s", string); } else if (xmlStrcasecmp(local, (xmlChar *)"relation") == 0) { AddNode(meta->relation, NewListNode(meta->relation, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "relation is %s", string); } else if (xmlStrcasecmp(local, (xmlChar *)"coverage") == 0) { AddNode(meta->coverage, NewListNode(meta->coverage, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "coverage is %s", string); } else if (xmlStrcasecmp(local, (xmlChar *)"rights") == 0) { AddNode(meta->rights, NewListNode(meta->rights, string)); _epub_print_debug(opf->epub, DEBUG_INFO, "rights is %s", string); } else if (string) { if (xmlStrcasecmp(local, (xmlChar *)"dc-metadata") != 0 && xmlStrcasecmp(local, (xmlChar *)"x-metadata") != 0) _epub_print_debug(opf->epub, DEBUG_INFO, "unsupported local %s: %s", local, string); free(string); } ret = xmlTextReaderRead(reader); } } struct toc *_opf_init_toc() { struct toc *toc = malloc(sizeof(struct toc)); memset(toc, 0, sizeof(struct toc)); toc->playOrder = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)_list_cmp_toc_by_playorder); return toc; } struct tocCategory *_opf_init_toc_category() { struct tocCategory *tc = malloc(sizeof(struct tocCategory)); memset(tc, 0, sizeof(struct tocCategory)); tc->info = NewListAlloc(LIST, NULL, NULL, NULL); //tocLabel tc->label = NewListAlloc(LIST, NULL, NULL, NULL); //tocLabel tc->items = NewListAlloc(LIST, NULL, NULL, NULL); //tocItem return tc; } void _opf_free_toc_category(struct tocCategory *tc) { if (tc->id) free(tc->id); if (tc->class) free(tc->class); FreeList(tc->info, (ListFreeFunc)_list_free_toc_label); FreeList(tc->label, (ListFreeFunc)_list_free_toc_label); FreeList(tc->items, (ListFreeFunc)_list_free_toc_item); free(tc); } void _opf_free_toc(struct toc *toc) { if (toc->navMap) _opf_free_toc_category(toc->navMap); if (toc->navList) _opf_free_toc_category(toc->navList); if (toc->pageList) _opf_free_toc_category(toc->pageList); // all items are already free, lets free only the struct FreeList(toc->playOrder, NULL); free(toc); } // Parse a navLabel or navInfo returns NULL on failure and the label on success struct tocLabel *_opf_parse_navlabel(struct opf *opf, xmlTextReaderPtr reader) { int ret; struct tocLabel *new = malloc(sizeof(struct tocLabel)); memset(new, 0, sizeof(struct tocLabel)); new->lang = xmlTextReaderGetAttribute(reader, (xmlChar *)"lang"); new->dir = xmlTextReaderGetAttribute(reader, (xmlChar *)"dir"); ret = xmlTextReaderRead(reader); while (ret == 1 && xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navLabel") && xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navInfo")) { if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"text") && xmlTextReaderNodeType(reader) == 1) { new->text = (xmlChar *)xmlTextReaderReadString(reader); } ret = xmlTextReaderRead(reader); } if (ret != 1) { free(new); return NULL; } _epub_print_debug(opf->epub, DEBUG_INFO, "parsing label/info %s(%s/%s)", new->text, new->lang, new->dir); return new; } struct tocItem *_opf_init_toc_item(int depth) { struct tocItem *item = malloc(sizeof(struct tocItem)); memset(item, 0, sizeof(struct tocItem)); item->depth = depth; item->playOrder = -1; item->value = -1; return item; } int _get_attribute_as_positive_int(xmlTextReaderPtr reader, const xmlChar *name) { xmlChar *str = xmlTextReaderGetAttribute(reader, name); int ret = -1; if (str) { ret = atoi((char *)str); free(str); } return ret; } void _opf_parse_navmap(struct opf *opf, xmlTextReaderPtr reader) { int ret; int depth = 0; struct tocCategory *tc = _opf_init_toc_category(); struct tocItem *item = NULL; _epub_print_debug(opf->epub, DEBUG_INFO, "parsing nav map"); tc->id = xmlTextReaderGetAttribute(reader, (xmlChar *)"id"); ret = xmlTextReaderRead(reader); while (ret == 1 && xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navMap")) { if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navPoint")) { if (xmlTextReaderNodeType(reader) == 1) { if (item) { _epub_print_debug(opf->epub, DEBUG_INFO, "adding nav point item->%s %s (d:%d,p:%d)", item->id, item->src, item->depth, item->playOrder); AddNode(tc->items, NewListNode(tc->items, item)); AddNode(opf->toc->playOrder, NewListNode(opf->toc->playOrder, item)); item = NULL; } depth++; item = _opf_init_toc_item(depth); item->id = xmlTextReaderGetAttribute(reader, (xmlChar *)"id"); item->class = xmlTextReaderGetAttribute(reader, (xmlChar *)"class"); item->playOrder = _get_attribute_as_positive_int(reader, (xmlChar *)"playOrder"); if (item->playOrder == -1) { _epub_print_debug(opf->epub, DEBUG_WARNING, "- missing play order in nav point element"); } } else if (xmlTextReaderNodeType(reader) == 15) { if (item) { _epub_print_debug(opf->epub, DEBUG_INFO, "adding nav point item->%s %s (d:%d,p:%d)", item->id, item->src, item->depth, item->playOrder); AddNode(tc->items, NewListNode(tc->items, item)); AddNode(opf->toc->playOrder, NewListNode(opf->toc->playOrder, item)); item = NULL; } depth--; } } // ignore non starting tags if (xmlTextReaderNodeType(reader) != 1) { ret = xmlTextReaderRead(reader); continue; } if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navLabel")) { if (item) { if (! item->label) item->label = NewListAlloc(LIST, NULL, NULL, NULL); //tocLabel AddNode(item->label, NewListNode(item->label, _opf_parse_navlabel(opf, reader))); } else { // Not inside navpoint AddNode(tc->label, NewListNode(tc->label, _opf_parse_navlabel(opf, reader))); } } else if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navInfo")) { AddNode(tc->info, NewListNode(tc->info, _opf_parse_navlabel(opf, reader))); if (item) _epub_print_debug(opf->epub, DEBUG_WARNING, "nav info inside nav point element"); } else if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"content")) { if (item) item->src = xmlTextReaderGetAttribute(reader, (xmlChar *)"src"); else _epub_print_debug(opf->epub, DEBUG_WARNING, "content not inside nav point element"); } ret = xmlTextReaderRead(reader); } opf->toc->navMap = tc; _epub_print_debug(opf->epub, DEBUG_INFO, "finished parsing nav map"); } void _opf_parse_navlist(struct opf *opf, xmlTextReaderPtr reader) { int ret; struct tocCategory *tc = _opf_init_toc_category(); struct tocItem *item = NULL; tc->id = xmlTextReaderGetAttribute(reader, (xmlChar *)"id"); tc->class = xmlTextReaderGetAttribute(reader, (xmlChar *)"class"); _epub_print_debug(opf->epub, DEBUG_INFO, "parsing nav list"); ret = xmlTextReaderRead(reader); while (ret == 1 && xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navList")) { if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navTarget")) { if (xmlTextReaderNodeType(reader) == 1) { item = _opf_init_toc_item(1); item->id = xmlTextReaderGetAttribute(reader, (xmlChar *)"id"); item->class = xmlTextReaderGetAttribute(reader, (xmlChar *)"class"); item->playOrder = _get_attribute_as_positive_int(reader, (xmlChar *)"playOrder"); if (item->playOrder == -1) { _epub_print_debug(opf->epub, DEBUG_WARNING, "- missing play order in nav target element"); } item->value = _get_attribute_as_positive_int(reader, (xmlChar *)"value"); } else if (xmlTextReaderNodeType(reader) == 15) { if (item) { _epub_print_debug(opf->epub, DEBUG_INFO, "adding nav target item->%s %s (d:%d,p:%d)", item->id, item->src, item->depth, item->playOrder); AddNode(tc->items, NewListNode(tc->items, item)); AddNode(opf->toc->playOrder, NewListNode(opf->toc->playOrder, item)); item = NULL; } else { _epub_print_debug(opf->epub, DEBUG_ERROR, "empty item in nav list"); } } } // ignore non starting tags if (xmlTextReaderNodeType(reader) != 1) { ret = xmlTextReaderRead(reader); continue; } if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navLabel")) { if (item) { if (! item->label) item->label = NewListAlloc(LIST, NULL, NULL, NULL); //tocLabel AddNode(item->label, NewListNode(item->label, _opf_parse_navlabel(opf, reader))); } else { // Not inside navpoint AddNode(tc->label, NewListNode(tc->label, _opf_parse_navlabel(opf, reader))); } } else if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navInfo")) { AddNode(tc->info, NewListNode(tc->info, _opf_parse_navlabel(opf, reader))); if (item) _epub_print_debug(opf->epub, DEBUG_WARNING, "nav info inside nav target element"); } else if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"content")) { if (item) item->src = xmlTextReaderGetAttribute(reader, (xmlChar *)"src"); else _epub_print_debug(opf->epub, DEBUG_WARNING, "content not inside nav target element"); } ret = xmlTextReaderRead(reader); } opf->toc->navList = tc; _epub_print_debug(opf->epub, DEBUG_INFO, "finished parsing nav list"); } void _opf_parse_pagelist(struct opf *opf, xmlTextReaderPtr reader) { int ret; struct tocCategory *tc = _opf_init_toc_category(); struct tocItem *item = NULL; tc->id = xmlTextReaderGetAttribute(reader, (xmlChar *)"id"); tc->class = xmlTextReaderGetAttribute(reader, (xmlChar *)"class"); _epub_print_debug(opf->epub, DEBUG_INFO, "parsing page list"); ret = xmlTextReaderRead(reader); while (ret == 1 && xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"pageList")) { if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"pageTarget")) { if (xmlTextReaderNodeType(reader) == 1) { item = _opf_init_toc_item(1); item->id = xmlTextReaderGetAttribute(reader, (xmlChar *)"id"); item->class = xmlTextReaderGetAttribute(reader, (xmlChar *)"class"); item->type = xmlTextReaderGetAttribute(reader, (xmlChar *)"type"); item->playOrder = _get_attribute_as_positive_int(reader, (xmlChar *)"playOrder"); if (item->playOrder == -1) { _epub_print_debug(opf->epub, DEBUG_WARNING, "- missing play order in page target element"); } item->value = _get_attribute_as_positive_int(reader, (xmlChar *)"value"); } else if (xmlTextReaderNodeType(reader) == 15) { if (item) { _epub_print_debug(opf->epub, DEBUG_INFO, "adding page target item->%s %s (d:%d,p:%d)", item->id, item->src, item->depth, item->playOrder); AddNode(tc->items, NewListNode(tc->items, item)); AddNode(opf->toc->playOrder, NewListNode(opf->toc->playOrder, item)); item = NULL; } else { _epub_print_debug(opf->epub, DEBUG_ERROR, "empty item in nav list"); } } } // ignore non starting tags if (xmlTextReaderNodeType(reader) != 1) { ret = xmlTextReaderRead(reader); continue; } if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navLabel")) { if (item) { if (! item->label) item->label = NewListAlloc(LIST, NULL, NULL, NULL); //tocLabel AddNode(item->label, NewListNode(item->label, _opf_parse_navlabel(opf, reader))); } else { // Not inside navpoint AddNode(tc->label, NewListNode(tc->label, _opf_parse_navlabel(opf, reader))); } } else if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"navInfo")) { AddNode(tc->info, NewListNode(tc->info, _opf_parse_navlabel(opf, reader))); if (item) _epub_print_debug(opf->epub, DEBUG_WARNING, "nav info inside page target element"); } else if (! xmlStrcasecmp(xmlTextReaderConstName(reader),(xmlChar *)"content")) { if (item) item->src = xmlTextReaderGetAttribute(reader, (xmlChar *)"src"); else _epub_print_debug(opf->epub, DEBUG_WARNING, "content not inside nav target element"); } ret = xmlTextReaderRead(reader); } opf->toc->navList = tc; _epub_print_debug(opf->epub, DEBUG_INFO, "finished parsing page list"); } void _opf_parse_toc(struct opf *opf, char *tocStr, int size) { xmlTextReaderPtr reader; int ret; _epub_print_debug(opf->epub, DEBUG_INFO, "building toc"); opf->toc = _opf_init_toc(); _epub_print_debug(opf->epub, DEBUG_INFO, "parsing toc"); reader = xmlReaderForMemory(tocStr, size, "TOC", NULL, 0); if (reader != NULL) { ret = xmlTextReaderRead(reader); while (ret == 1) { const xmlChar *name = xmlTextReaderConstName(reader); if (xmlStrcasecmp(name, (xmlChar *)"navList") == 0) _opf_parse_navlist(opf, reader); else if (xmlStrcasecmp(name, (xmlChar *)"navMap") == 0) _opf_parse_navmap(opf, reader); else if (xmlStrcasecmp(name, (xmlChar *)"pageList") == 0) _opf_parse_pagelist(opf, reader); ret = xmlTextReaderRead(reader); } xmlFreeTextReader(reader); if (ret != 0) { _epub_print_debug(opf->epub, DEBUG_ERROR, "failed to parse toc"); } } else { _epub_print_debug(opf->epub, DEBUG_ERROR, "unable to open toc reader"); } SortList(opf->toc->playOrder); _epub_print_debug(opf->epub, DEBUG_INFO, "finished parsing toc"); } void _opf_parse_spine(struct opf *opf, xmlTextReaderPtr reader) { int ret; xmlChar *linear; _epub_print_debug(opf->epub, DEBUG_INFO, "parsing spine"); opf->spine = NewListAlloc(LIST, NULL, NULL, NULL); opf->tocName = xmlTextReaderGetAttribute(reader, (xmlChar *)"toc"); if (opf->tocName) { char *tocStr = NULL; struct manifest *item; int size; _epub_print_debug(opf->epub, DEBUG_INFO, "toc is %s", opf->tocName); item = _opf_manifest_get_by_id(opf, opf->tocName); if (item != NULL) { size = _ocf_get_data_file(opf->epub->ocf, (char *)item->href, &tocStr); if (size <= 0) { _epub_print_debug(opf->epub, DEBUG_ERROR, "Faulty toc file %s", opf->tocName); } else { _opf_parse_toc(opf, tocStr, size); free(tocStr); } } else { _epub_print_debug(opf->epub, DEBUG_ERROR, "Toc not in manifest (-) %s", opf->tocName); } } else { _epub_print_debug(opf->epub, DEBUG_WARNING, "toc not found (-)"); opf->toc = NULL; } ret = xmlTextReaderRead(reader); while (ret == 1 && xmlStrcasecmp(xmlTextReaderConstLocalName(reader), (xmlChar *)"spine")) { struct spine *item; // ignore non starting tags if (xmlTextReaderNodeType(reader) != 1) { ret = xmlTextReaderRead(reader); continue; } item = malloc(sizeof(struct spine)); memset(item, 0, sizeof(struct spine)); item->idref = xmlTextReaderGetAttribute(reader, (xmlChar *)"idref"); linear = xmlTextReaderGetAttribute(reader, (xmlChar *)"linear"); if (linear && xmlStrcasecmp(linear, (xmlChar *)"no") == 0) { item->linear = 0; } else { item->linear = 1; opf->linearCount++; } if(linear) free(linear); AddNode(opf->spine, NewListNode(opf->spine, item)); // decide what to do with non linear items _epub_print_debug(opf->epub, DEBUG_INFO, "found item %s", item->idref); ret = xmlTextReaderRead(reader); } } void _opf_parse_manifest(struct opf *opf, xmlTextReaderPtr reader) { int ret; _epub_print_debug(opf->epub, DEBUG_INFO, "parsing manifest"); opf->manifest = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)_list_cmp_manifest_by_id ); ret = xmlTextReaderRead(reader); while (ret == 1 && xmlStrcasecmp(xmlTextReaderConstLocalName(reader),(xmlChar *)"manifest")) { struct manifest *item; // ignore non starting tags if (xmlTextReaderNodeType(reader) != 1) { ret = xmlTextReaderRead(reader); continue; } item = malloc(sizeof(struct manifest)); item->id = xmlTextReaderGetAttribute(reader, (xmlChar *)"id"); item->href = xmlTextReaderGetAttribute(reader, (xmlChar *)"href"); item->type = xmlTextReaderGetAttribute(reader, (xmlChar *)"media-type"); item->fallback = xmlTextReaderGetAttribute(reader, (xmlChar *)"fallback"); item->fbStyle = xmlTextReaderGetAttribute(reader, (xmlChar *)"fallback-style"); item->nspace = xmlTextReaderGetAttribute(reader, (xmlChar *)"required-namespace"); item->modules = xmlTextReaderGetAttribute(reader, (xmlChar *)"required-modules"); _epub_print_debug(opf->epub, DEBUG_INFO, "manifest item %s href %s media-type %s", item->id, item->href, item->type); AddNode(opf->manifest, NewListNode(opf->manifest, item)); ret = xmlTextReaderRead(reader); } } struct manifest *_opf_manifest_get_by_id(struct opf *opf, xmlChar* id) { struct manifest data; data.id = id; return FindNode(opf->manifest, &data); } void _opf_parse_guide(struct opf *opf, xmlTextReaderPtr reader) { int ret; struct guide *item; _epub_print_debug(opf->epub, DEBUG_INFO, "parsing guides"); opf->guide = NewListAlloc(LIST, NULL, NULL, NULL); ret = xmlTextReaderRead(reader); while (ret == 1 && xmlStrcasecmp(xmlTextReaderConstLocalName(reader),(xmlChar *)"guides")) { // ignore non starting tags if (xmlTextReaderNodeType(reader) != 1) { ret = xmlTextReaderRead(reader); continue; } item = malloc(sizeof(struct guide)); item->type = xmlTextReaderGetAttribute(reader, (xmlChar *)"type"); item->title = xmlTextReaderGetAttribute(reader, (xmlChar *)"title"); item->href = xmlTextReaderGetAttribute(reader, (xmlChar *)"href"); _epub_print_debug(opf->epub, DEBUG_INFO, "guide item: %s href: %s type: %s", item->title, item->href, item->type); AddNode(opf->guide, NewListNode(opf->guide, item)); ret = xmlTextReaderRead(reader); } } listPtr _opf_parse_tour(struct opf *opf, xmlTextReaderPtr reader) { int ret; listPtr tour = NewListAlloc(LIST, NULL, NULL, NULL); struct site *item; ret = xmlTextReaderRead(reader); while (ret == 1 && xmlStrcasecmp(xmlTextReaderConstLocalName(reader),(xmlChar *)"tour")) { // ignore non starting tags if (xmlTextReaderNodeType(reader) != 1) { ret = xmlTextReaderRead(reader); continue; } item = malloc(sizeof(struct site)); item->title = xmlTextReaderGetAttribute(reader, (xmlChar *)"title"); item->href = xmlTextReaderGetAttribute(reader, (xmlChar *)"href"); _epub_print_debug(opf->epub, DEBUG_INFO, "site: %s href: %s", item->title, item->href); AddNode(tour, NewListNode(tour, item)); ret = xmlTextReaderRead(reader); } return tour; } void _opf_parse_tours(struct opf *opf, xmlTextReaderPtr reader) { int ret; struct tour *item; _epub_print_debug(opf->epub, DEBUG_INFO, "parsing tours"); opf->tours = NewListAlloc(LIST, NULL, NULL, NULL); ret = xmlTextReaderRead(reader); while (ret == 1 && xmlStrcasecmp(xmlTextReaderConstLocalName(reader), (xmlChar *)"tours")) { // ignore non starting tags if (xmlTextReaderNodeType(reader) != 1) { ret = xmlTextReaderRead(reader); continue; } item = malloc(sizeof(struct tour)); item->title = xmlTextReaderGetAttribute(reader, (xmlChar *)"title"); item->id = xmlTextReaderGetAttribute(reader, (xmlChar *)"id"); _epub_print_debug(opf->epub, DEBUG_INFO, "tour: %s id: %s", item->title, item->id); item->sites = _opf_parse_tour(opf, reader); AddNode(opf->tours, NewListNode(opf->tours, item)); ret = xmlTextReaderRead(reader); } } xmlChar *_opf_label_get_by_lang(struct opf *opf, listPtr label, char *lang) { struct tocLabel data, *tmp; data.lang = (xmlChar *)lang; label->compare = (NodeCompareFunc)_list_cmp_label_by_lang; tmp = FindNode(label, &data); return (tmp?tmp->text:NULL); } xmlChar *_opf_label_get_by_doc_lang(struct opf *opf, listPtr label) { opf->metadata->lang->Current = opf->metadata->lang->Head; return _opf_label_get_by_lang(opf, label, (char *)GetNode(opf->metadata->lang)); } void _opf_dump(struct opf *opf) { printf("Title(s):\n "); DumpList(opf->metadata->title, (ListDumpFunc)_list_dump_string); printf("Creator(s):\n "); DumpList(opf->metadata->creator, (ListDumpFunc)_list_dump_creator); printf("Identifier(s):\n "); DumpList(opf->metadata->id, (ListDumpFunc)_list_dump_id); printf("Reading order:\n "); DumpList(opf->spine, (ListDumpFunc)_list_dump_spine); printf("\n"); if (opf->guide) { printf("Guide:\n"); DumpList(opf->guide, (ListDumpFunc)_list_dump_guide); } if (opf->tours) DumpList(opf->tours, (ListDumpFunc)_list_dump_tour); if (opf->metadata->meta->Size != 0) { printf("Extra local metadata:\n"); DumpList(opf->metadata->meta, (ListDumpFunc)_list_dump_meta); } } void _opf_close(struct opf *opf) { if (opf->metadata) _opf_free_metadata(opf->metadata); if (opf->toc) _opf_free_toc(opf->toc); if (opf->spine) FreeList(opf->spine, (ListFreeFunc)_list_free_spine); if (opf->tocName) free(opf->tocName); if (opf->manifest) FreeList(opf->manifest, (ListFreeFunc)_list_free_manifest); if (opf->guide) FreeList(opf->guide, (ListFreeFunc)_list_free_guide); if (opf->tours) FreeList(opf->tours, (ListFreeFunc)_list_free_tours); free(opf); } ebook-tools-0.2.2/src/libepub/ocf.c0000644000530500000060000002024512021410400016647 0ustar elylevysystem#include "epublib.h" int _ocf_parse_mimetype(struct ocf *ocf) { _epub_print_debug(ocf->epub, DEBUG_INFO, "looking for mime type"); // Figure out mime type if (_ocf_get_file(ocf, MIMETYPE_FILENAME, &ocf->mimetype) == -1) { _epub_print_debug(ocf->epub, DEBUG_WARNING, "Can't get mimetype, assuming application/epub+zip (-)"); ocf->mimetype = malloc(sizeof(char) * strlen("application/epub+zip")+1); if (! ocf->mimetype) { _epub_print_debug(ocf->epub, DEBUG_ERROR, "no memory for mimetype"); return -1; } strcpy(ocf->mimetype, "application/epub+zip"); } else { _epub_print_debug(ocf->epub, DEBUG_INFO, "mimetype found %s", ocf->mimetype); } return 1; } int _ocf_parse_container(struct ocf *ocf) { char *containerXml = NULL; const char *name = CONTAINER_FILENAME; xmlTextReaderPtr reader; int ret; _epub_print_debug(ocf->epub, DEBUG_INFO, "parsing container file %s", METAINFO_DIR "/" CONTAINER_FILENAME); if (_ocf_get_file(ocf, METAINFO_DIR "/" CONTAINER_FILENAME, &containerXml) == -1) return 0; reader = xmlReaderForMemory(containerXml, strlen(containerXml), name, NULL, 0); if (reader != NULL) { ret = xmlTextReaderRead(reader); while (ret == 1) { // Checking for container tag for validation if(xmlStrcasecmp(xmlTextReaderConstLocalName(reader), (xmlChar *)"container") == 0) { _epub_print_debug(ocf->epub, DEBUG_INFO, "Found containerr"); // Checking for rootfiles tag for validation } else if(xmlStrcasecmp(xmlTextReaderConstLocalName(reader), (xmlChar *)"rootfiles") == 0) { _epub_print_debug(ocf->epub, DEBUG_INFO, "Found rootfiles"); } else if (xmlStrcasecmp(xmlTextReaderConstLocalName(reader), (xmlChar *)"rootfile") == 0) { struct root *newroot = malloc(sizeof(struct root)); if (! newroot) { _epub_print_debug(ocf->epub, DEBUG_ERROR, "No memory left for root"); xmlFreeTextReader(reader); free(containerXml); return 0; } newroot->mediatype = xmlTextReaderGetAttribute(reader, (xmlChar *)"media-type"); newroot->fullpath = xmlTextReaderGetAttribute(reader, (xmlChar *)"full-path"); AddNode(ocf->roots, NewListNode(ocf->roots, newroot)); _epub_print_debug(ocf->epub, DEBUG_INFO, "found root in %s media-type is %s", newroot->fullpath, newroot->mediatype); } ret = xmlTextReaderRead(reader); } xmlFreeTextReader(reader); free(containerXml); if (ret != 0) { _epub_print_debug(ocf->epub, DEBUG_ERROR, "failed to parse %s\n", name); return 0; } } else { _epub_print_debug(ocf->epub, DEBUG_ERROR, "unable to open %s\n", name); return 0; } return 1; } void _ocf_dump(struct ocf *ocf) { printf("Filename:\t %s\n", ocf->filename); printf("Root(s):\n"); DumpList(ocf->roots, (ListDumpFunc)_list_dump_root); } struct zip *_ocf_open(struct ocf *ocf, const char *filename) { int err; char errStr[8192]; struct zip *arch = NULL; if (! (arch = zip_open(filename, 0, &err))) { zip_error_to_str(errStr, sizeof(errStr), err, errno); _epub_print_debug(ocf->epub, DEBUG_ERROR, "%s - %s", filename, errStr); } return arch; } void _ocf_close(struct ocf *ocf) { if (ocf->arch) { if (zip_close(ocf->arch) == -1) { _epub_print_debug(ocf->epub, DEBUG_ERROR, "%s - %s\n", ocf->filename, zip_strerror(ocf->arch)); } } FreeList(ocf->roots, (ListFreeFunc)_list_free_root); if (ocf->filename) free(ocf->filename); if (ocf->mimetype) free(ocf->mimetype); if (ocf->datapath) free(ocf->datapath); free(ocf); } // returns index if file exists else -1 int _ocf_check_file(struct ocf *ocf, const char *filename) { return zip_name_locate(ocf->arch, filename, 0); } // Get the file named filename from epub zip and pub it in fileStr // Returns the size of the file or -1 on failure int _ocf_get_file(struct ocf *ocf, const char *filename, char **fileStr) { struct epub *epub = ocf->epub; struct zip *arch = ocf->arch; struct zip_file *file = NULL; struct zip_stat fileStat; int size; zip_stat_init(&fileStat); *fileStr = NULL; if (zip_stat(arch, filename, ZIP_FL_UNCHANGED, &fileStat) == -1) { _epub_print_debug(epub, DEBUG_INFO, "%s - %s", filename, zip_strerror(arch)); return -1; } if (! (file = zip_fopen_index(arch, fileStat.index, ZIP_FL_NODIR))) { _epub_print_debug(epub, DEBUG_INFO, "%s - %s", filename, zip_strerror(arch)); return -1; } *fileStr = (char *)malloc((fileStat.size+1)* sizeof(char)); if (! fileStr) { _epub_print_debug(epub, DEBUG_ERROR, "Failed to allocate memory for file string"); return -1; } if ((size = zip_fread(file, *fileStr, fileStat.size)) == -1) { _epub_print_debug(epub, DEBUG_INFO, "%s - %s", filename, zip_strerror(arch)); } else { (*fileStr)[size] = 0; } if (zip_fclose(file) == -1) { _epub_print_debug(epub, DEBUG_INFO, "%s - %s", filename, zip_strerror(arch)); free(*fileStr); *fileStr = NULL; return -1; } if (epub->debug >= DEBUG_VERBOSE) { _epub_print_debug(epub, DEBUG_VERBOSE, "--------- Begin %s", filename); fprintf(stderr, "%s\n", (*fileStr)); _epub_print_debug(epub, DEBUG_VERBOSE, "--------- End %s", filename); } return size; } void _ocf_not_supported(struct ocf *ocf, const char *filename) { if (_ocf_check_file(ocf, filename) > -1) _epub_print_debug(ocf->epub, DEBUG_WARNING, "file %s exists but is not supported by this version", filename); } struct ocf *_ocf_parse(struct epub *epub, const char *filename) { struct ocf *ocf; _epub_print_debug(epub, DEBUG_INFO, "building ocf struct"); ocf = malloc(sizeof(struct ocf)); if (!ocf) { _epub_err_set_oom(&epub->error); return NULL; } memset(ocf, 0, sizeof(struct ocf)); ocf->epub = epub; ocf->roots = NewListAlloc(LIST, NULL, NULL, (NodeCompareFunc)_list_cmp_root_by_mediatype); ocf->filename = malloc(sizeof(char)*(strlen(filename)+1)); if ( ! ocf->filename) { _epub_print_debug(epub, DEBUG_ERROR, "Failed to allocate memory for filename"); return NULL; } strcpy(ocf->filename, filename); if (! (ocf->arch = _ocf_open(ocf, ocf->filename))) { _ocf_close(ocf); return NULL; } // Find the mime type if (_ocf_parse_mimetype(ocf) == -1) { _ocf_close(ocf); return NULL; } // Parse the container for roots _ocf_parse_container(ocf); // Unsupported files _ocf_not_supported(ocf, METAINFO_DIR "/" MANIFEST_FILENAME); _ocf_not_supported(ocf, METAINFO_DIR "/" METADATA_FILENAME); _ocf_not_supported(ocf, METAINFO_DIR "/" SIGNATURES_FILENAME); _ocf_not_supported(ocf, METAINFO_DIR "/" ENCRYPTION_FILENAME); _ocf_not_supported(ocf, METAINFO_DIR "/" RIGHTS_FILENAME); return ocf; } int _ocf_get_data_file(struct ocf *ocf, const char *filename, char **fileStr) { int size; char *fullname; if (! filename) { return -1; } fullname = malloc((strlen(filename)+strlen(ocf->datapath)+1)*sizeof(char)); if (!fullname) { _epub_print_debug(ocf->epub, DEBUG_ERROR, "Failed to allocate memory for file name"); return -1; } strcpy(fullname, ocf->datapath); strcat(fullname, filename); size = _ocf_get_file(ocf, fullname, fileStr); free(fullname); return size; } char *_ocf_root_fullpath_by_type(struct ocf *ocf, const char *type) { struct root look = {(xmlChar *)type, NULL}; struct root *res; res = FindNode(ocf->roots, &look); if (res) return strdup((char *)res->fullpath); _epub_print_debug(ocf->epub, DEBUG_WARNING, "type %s for root not found", type); return NULL; } char *_ocf_root_by_type(struct ocf *ocf, const char *type) { struct root look = {(xmlChar *)type, NULL}; struct root *res; char *rootXml = NULL; res = FindNode(ocf->roots, &look); if (res) _ocf_get_file(ocf, (char *)res->fullpath, &rootXml); if (! rootXml) _epub_print_debug(ocf->epub, DEBUG_WARNING, "type %s for root not found", type); return rootXml; } ebook-tools-0.2.2/src/libepub/epub_shared.h0000644000530500000060000000251012021410400020361 0ustar elylevysystem#ifndef EPUB_SHARED_H #define EPUB_SHARED_H 1 #ifdef _WIN32 # ifdef epub_EXPORTS # define EPUB_EXPORT __declspec(dllexport) # else # define EPUB_EXPORT __declspec(dllimport) # endif #else # define EPUB_EXPORT #endif /** Metadata types */ enum epub_metadata { EPUB_ID, /**< ebook id*/ EPUB_TITLE, /**< ebook title*/ EPUB_CREATOR, /**< ebook creator*/ EPUB_CONTRIB, /**< ebook contributor*/ EPUB_SUBJECT, /**< ebook subject*/ EPUB_PUBLISHER, /**< ebook publisher*/ EPUB_DESCRIPTION, /**< ebook description*/ EPUB_DATE, /**< ebook data */ EPUB_TYPE, /**< ebook type */ EPUB_FORMAT, /**< ebook format */ EPUB_SOURCE, /**< ebook source */ EPUB_LANG, /**< ebook language */ EPUB_RELATION, /**< ebook relation*/ EPUB_COVERAGE, /**< ebook coverage*/ EPUB_RIGHTS,/**< ebook rights */ EPUB_META /**< ebook extra metadata*/ }; /** Ebook Iterator types */ enum eiterator_type { EITERATOR_SPINE, /**< all the spine */ EITERATOR_LINEAR, /**< the linear reading spine parts */ EITERATOR_NONLINEAR /**< the non linear reading spine parts */ /* EITERATOR_TOUR */ }; /** Ebook Table Of Content Iterator types */ enum titerator_type { TITERATOR_NAVMAP, /**< Navigation map */ TITERATOR_GUIDE, /**< Guide to the ebook parts */ TITERATOR_PAGES /**< The pages of the ebook */ }; #endif ebook-tools-0.2.2/src/libepub/epub.h0000644000530500000060000001347212021410400017044 0ustar elylevysystem#ifndef EPUB_H #define EPUB_H 1 #include /** \struct epub is a private struct containting information about the epub file */ struct epub; /** \struct eiterator is a private iterator struct */ struct eiterator; struct titerator; #ifdef __cplusplus extern "C" { #endif /* C++ */ /** This function accepts an epub filename. It then parses its information and returns it as an epub struct. @param filename the name of the file to open @param debug is the debug level (0=none, 1=errors, 2=warnings, 3=info) @return epub struct with the information of the file or NULL on error */ EPUB_EXPORT struct epub *epub_open(const char *filename, int debug); /** This function sets the debug level to the given level. @param filename is the name of the file to open @param debug is the debug level (0=none, 1=errors, 2=warnings, 3=info) */ EPUB_EXPORT void epub_set_debug(struct epub *epub, int debug); /** returns the file with the give filename @param epub struct of the epub file we want to read from @param filename the name of the file we want to read @param pointer to where the file data is stored @return the number of bytes read */ EPUB_EXPORT int epub_get_ocf_file(struct epub *epub, const char *filename, char **data); /** Frees the memory held by the given iterator @param it the iterator */ EPUB_EXPORT void epub_free_iterator(struct eiterator *it); /** This function closes a given epub. It also frees the epub struct. So you can use it after calling this function. @param epub the struct of the epub to close. */ EPUB_EXPORT int epub_close(struct epub *epub); /** Debugging function dumping various file information. @param epub the struct of the epub to close. */ EPUB_EXPORT void epub_dump(struct epub *epub); /** (Bad xml might cause some of it to be NULL). @param epub the struct . */ EPUB_EXPORT unsigned char **epub_get_metadata(struct epub *epub, enum epub_metadata type, int *size); /** returns the file with the give filename. The file is looked for in the data directory. (Useful for getting book files). @param epub struct of the epub file we want to read from @param filename the name of the file we want to read @param pointer to where the file data is stored @return the number of bytes read */ EPUB_EXPORT int epub_get_data(struct epub *epub, const char *name, char **data); /** Returns a book iterator of the requested type for the given epub struct. @param epub struct of the epub file @param type the iterator type @param opt other options (ignored for now) @return eiterator to the epub book */ EPUB_EXPORT struct eiterator *epub_get_iterator(struct epub *epub, enum eiterator_type type, int opt); /** updates the iterator to the next element and returns a pointer to the data. the iterator handles the freeing of the memory. @param it the iterator @return pointer to the data */ EPUB_EXPORT char *epub_it_get_next(struct eiterator *it); /** Returns a pointer to the iterator's data. the iterator handles the freeing of the memory. @param it the iterator @return pointer to the data */ EPUB_EXPORT char *epub_it_get_curr(struct eiterator *it); /** Returns a pointer to the url of the iterator's current data. the iterator handles the freeing of the memory. @param it the iterator @return pointer to the current data's url */ EPUB_EXPORT char *epub_it_get_curr_url(struct eiterator *it); /** Returns a book toc iterator of the requested type for the given epub struct. @param epub struct of the epub file @param type the iterator type @param opt other options (ignored for now) @return toc iterator to the epub book */ EPUB_EXPORT struct titerator *epub_get_titerator(struct epub *epub, enum titerator_type type, int opt); /** Returns 1 if the current entry is valid and 0 otherwise. @param tit the iterator @return 1 if the current entry is valid and 0 otherwise */ EPUB_EXPORT int epub_tit_curr_valid(struct titerator *tit); /** Returns a pointer to the depth of the toc iterator's current entry. the iterator handles the freeing of the memory. @param tit the iterator @return pointer to the current entry's depth */ EPUB_EXPORT int epub_tit_get_curr_depth(struct titerator *tit); /** Returns a pointer to the link of the toc iterator's current entry. the iterator handles the freeing of the memory. @param tit the iterator @return the current entry's depth */ EPUB_EXPORT char *epub_tit_get_curr_link(struct titerator *tit); /** Returns a pointer to the label of the toc iterator's current entry. the iterator handles the freeing of the memory. @param tit the iterator @return pointer to the current entry's lable */ EPUB_EXPORT char *epub_tit_get_curr_label(struct titerator *tit); /** Frees the memory held by the given iterator @param tit the iterator */ EPUB_EXPORT void epub_free_titerator(struct titerator *tit); /** updates the iterator to the next element. @param tit the iterator @return 1 on success and 0 otherwise */ EPUB_EXPORT int epub_tit_next(struct titerator *tit); /** Cleans up after the library. Call this when you are done with the library. */ EPUB_EXPORT void epub_cleanup(); #ifdef __cplusplus } #endif /* C++ */ #endif /* EPUB_H */ ebook-tools-0.2.2/src/libepub/list.c0000644000530500000060000001132512021410400017052 0ustar elylevysystem#include "epublib.h" // Free root struct void _list_free_root(struct root *data) { if (data->mediatype) free(data->mediatype); if (data->fullpath) free(data->fullpath); free(data); } void _list_free_creator(struct creator *data) { if (data->name) free(data->name); if (data->fileAs) free(data->fileAs); if (data->role) free(data->role); free(data); } void _list_free_date(struct date *data) { if (data->date) free(data->date); if (data->event) free(data->event); free(data); } void _list_free_id(struct id *data) { if (data->id) free(data->id); if (data->scheme) free(data->scheme); if (data->string) free(data->string); free(data); } void _list_free_meta(struct meta *data) { if (data->name) free(data->name); if (data->content) free(data->content); free(data); } void _list_free_spine(struct spine *spine) { if (spine->idref) free(spine->idref); free(spine); } void _list_free_guide(struct guide *guide) { if (guide->href) free(guide->href); if (guide->type) free(guide->type); if (guide->title) free(guide->title); free(guide); } void _list_free_site(struct site *site) { if (site->title) free(site->title); if (site->href) free(site->href); free(site); } void _list_free_tours(struct tour *tour) { if (tour->id) free(tour->id); if (tour->title) free(tour->title); FreeList(tour->sites, (ListFreeFunc)_list_free_site); free(tour); } void _list_free_manifest(struct manifest *manifest) { if (manifest->nspace) free(manifest->nspace); if (manifest->modules) free(manifest->modules); if (manifest->id) free(manifest->id); if (manifest->href) free(manifest->href); if (manifest->type) free(manifest->type); if (manifest->fallback) free(manifest->fallback); if (manifest->fbStyle) free(manifest->fbStyle); free(manifest); } void _list_free_toc_label(struct tocLabel *tl) { if (tl->lang) free(tl->lang); if (tl->dir) free(tl->dir); if (tl->text) free(tl->text); free(tl); } void _list_free_toc_item(struct tocItem *ti) { if (ti->id) free(ti->id); if (ti->src) free(ti->src); if (ti->class) free(ti->class); if (ti->type) free(ti->type); FreeList(ti->label, (ListFreeFunc)_list_free_toc_label); free(ti); } // Compare 2 root structs by mediatype field int _list_cmp_root_by_mediatype(struct root *root1, struct root *root2) { return strcmp((char *)root1->mediatype, (char *)root2->mediatype); } int _list_cmp_manifest_by_id(struct manifest *m1, struct manifest *m2) { return strcmp((char *)m1->id, (char *)m2->id); } int _list_cmp_label_by_lang(struct tocLabel *t1, struct tocLabel *t2) { if (! t1->lang || ! t2->lang) return 0; return strcmp((char *)t1->lang, (char *)t2->lang);; } int _list_cmp_toc_by_playorder(struct tocItem *t1, struct tocItem *t2) { if ((t1 == NULL) || (t2 == NULL)) return 0; if (t1->playOrder > t2->playOrder) return 1; if (t1->playOrder < t2->playOrder) return -1; return 0; } // Print root void _list_dump_root(struct root *root) { printf(" %s (%s)\n", root->fullpath, root->mediatype); } void _list_dump_spine(struct spine *spine) { printf("%s", spine->idref); if (spine->linear) printf("(L)"); printf(" "); } void _list_dump_spine_linear(struct spine *spine) { if (spine->linear) _list_dump_spine(spine); } void _list_dump_string(char *string) { printf("%s\n", string); } void _list_dump_creator(struct creator *data) { if (data->role) printf("%s", data->role); else printf("Author"); printf(": %s (%s)\n", data->name, ((data->fileAs)?data->fileAs:data->name)); } void _list_dump_meta(struct meta *meta) { if (meta->name) printf(" %s", meta->name); else printf("unspecified"); printf(" : "); if (meta->content) printf("%s", meta->content); else printf("unspecified"); printf("\n"); } void _list_dump_id(struct id *id) { printf("%s(", id->string); if (id->scheme) printf("%s", id->scheme); else printf("unspecified"); printf(":"); if (id->id) printf("%s", id->id); else printf("unspecified"); printf(")\n"); } void _list_dump_date(struct date *date) { if (date->event) printf("%s", date->event); else printf("unspecified"); printf(" : %s\n", date->date); } void _list_dump_guide(struct guide *guide) { printf(" %s -> %s(%s)\n", guide->title, guide->href, guide->type); } void _list_dump_site(struct site *site) { printf(" %s(%s)\n", site->title, site->href); } void _list_dump_tour(struct tour *tour) { printf("Tour %s(%s):\n", tour->title, tour->id); DumpList(tour->sites, (ListDumpFunc)_list_dump_site); } ebook-tools-0.2.2/src/tools/0000755000530500000060000000000012021410400015447 5ustar elylevysystemebook-tools-0.2.2/src/tools/einfo.c0000644000530500000060000000541712021410400016722 0ustar elylevysystem#include #include #include #include void quit(int code) { epub_cleanup(); exit(code); } void usage(int code) { fprintf(stderr, "Usage: einfo [options] \n"); fprintf(stderr, " -h\t Help message\n"); fprintf(stderr, " -q\t don't print short meta info summary\n"); fprintf(stderr, " -v\t Verbose (error)\n"); fprintf(stderr, " -vv\t Verbose (warnings)\n"); fprintf(stderr, " -vvv\t Verbose (info)\n"); fprintf(stderr, " -d\t Debug mode (implies -vvv)\n"); fprintf(stderr, " -p\t Linear print book (normal reading)\n"); fprintf(stderr, " -pp\t Print the whole book\n"); fprintf(stderr, " -t \t prints the tour \n"); exit(code); } int main(int argc , char **argv) { struct epub *epub; char *filename = NULL; char *tourId = NULL; int verbose = 0, print = 0, debug = 0, quiet = 0, tour = 0; int i, j, len; for (i = 1;i 1) { fprintf(stderr, "Only one tour at a time is supported\n"); usage(2); } i++; if (i 0) { struct eiterator *it; if (print > 1) { it = epub_get_iterator(epub, EITERATOR_LINEAR, 0); } else { it = epub_get_iterator(epub, EITERATOR_SPINE, 0); } do { if (epub_it_get_curr(it)) { printf("%s\n", epub_it_get_curr(it)); } } while (epub_it_get_next(it)); epub_free_iterator(it); } if (tour) { printf("Tours are still not supported\n"); } if (! epub_close(epub)) { quit(1); } quit(0); return 0; } ebook-tools-0.2.2/src/tools/lit2epub0000755000530500000060000000261212021410400017124 0ustar elylevysystem#!/bin/sh # Uses clit to convert .lit files to valid epub # known issues: created metadata uses the old spec check_tool() { var=$1 tool=$2 toolpath=$(which $tool 2>/dev/null) if [ "$?" != 0 ]; then echo "Cannot find $tool, please make sure it is in your PATH" exit 1 fi eval "$var=$toolpath" } check_tool CLIT clit check_tool ZIP zip LIT=$1 if [ "x$LIT" = "x" ]; then echo "$0 [file.epub]" exit 1; fi if [ "x$2" = "x" ]; then EPUB=$(echo $1 | sed -e 's/\.lit$/.epub/') else EPUB=$2 fi MKTEMP=$(which mktemp) if [ "$?" != 0 ]; then if [ ! -e /tmp/epub ]; then mkdir /tmp/epub else echo "/tmp/epub already exists please erase it first" exit 1 fi else TEMPDIR=$($MKTEMP -d) fi WD=$(pwd) IFS=' ' $CLIT $LIT $TEMPDIR/OEBPS/ find "$TEMPDIR"/OEBPS/ -name "*.opf" -exec mv {} "$TEMPDIR"/OEBPS/content.opf \; unset $IFS mkdir "$TEMPDIR/META-INF" cat << EOF > "$TEMPDIR/META-INF/container.xml" EOF printf 'application/epub+zip' > "$TEMPDIR"/mimetype IFS=' ' cd "$TEMPDIR" $ZIP -0 -m "$WD/$EPUB" mimetype $ZIP -rg "$WD/$EPUB" * cd $WD unset $IFS rm -rf $TEMPDIR ebook-tools-0.2.2/src/tools/CMakeLists.txt0000644000530500000060000000037412021410400020213 0ustar elylevysysteminclude_directories (${EBOOK-TOOLS_SOURCE_DIR}/src/libepub) add_executable (einfo einfo.c) target_link_libraries (einfo epub) install ( TARGETS einfo DESTINATION bin ) if(NOT WIN32) install ( PROGRAMS lit2epub DESTINATION bin ) endif(NOT WIN32) ebook-tools-0.2.2/cmake/0000755000530500000060000000000012021410400014600 5ustar elylevysystemebook-tools-0.2.2/cmake/FindLibZip.cmake0000644000530500000060000000217212021410400017576 0ustar elylevysystem# - Try to find libzip # Once done this will define # # LIBZIP_FOUND - system has the zip library # LIBZIP_INCLUDE_DIR - the zip include directory # LIBZIP_LIBRARY - Link this to use the zip library # # Copyright (c) 2006, Pino Toscano, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR) # in cache already set(LIBZIP_FOUND TRUE) else (LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR) find_path(LIBZIP_INCLUDE_DIR zip.h ${GNUWIN32_DIR}/include ) find_library(LIBZIP_LIBRARY NAMES zip PATHS ${GNUWIN32_DIR}/lib ) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibZip DEFAULT_MSG LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR) # ensure that they are cached set(LIBZIP_INCLUDE_DIR ${LIBZIP_INCLUDE_DIR} CACHE INTERNAL "The libzip include path") set(LIBZIP_LIBRARY ${LIBZIP_LIBRARY} CACHE INTERNAL "The libraries needed to use libzip") endif (LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR) mark_as_advanced(LIBZIP_INCLUDE_DIR LIBZIP_LIBRARY) ebook-tools-0.2.2/cmake/TargetDoc.cmake0000644000530500000060000001247412021410400017466 0ustar elylevysystem# -helper macro to add a "doc" target with CMake build system. # and configure doxy.config.in to doxy.config # # target "doc" allows building the documentation with doxygen/dot on WIN32 and Linux # Creates .chm windows help file if MS HTML help workshop # (available from http://msdn.microsoft.com/workshop/author/htmlhelp) # is installed with its DLLs in PATH. # # # Please note, that the tools, e.g.: # doxygen, dot, latex, dvips, makeindex, gswin32, etc. # must be in path. # # Note about Visual Studio Projects: # MSVS has its own path environment which may differ from the shell. # See "Menu Tools/Options/Projects/VC++ Directories" in VS 7.1 # # author Jan Woetzel 2004-2006 # www.mip.informatik.uni-kiel.de/~jw FIND_PACKAGE(Doxygen) IF (DOXYGEN_FOUND) # click+jump in Emacs and Visual Studio (for doxy.config) (jw) IF (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)") SET(DOXY_WARN_FORMAT "\"$file($line) : $text \"") ELSE (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)") SET(DOXY_WARN_FORMAT "\"$file:$line: $text \"") ENDIF (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)") # we need latex for doxygen because of the formulas FIND_PACKAGE(LATEX) IF (NOT LATEX_COMPILER) MESSAGE(STATUS "latex command LATEX_COMPILER not found but usually required. You will probably get warnings and user inetraction on doxy run.") ENDIF (NOT LATEX_COMPILER) IF (NOT MAKEINDEX_COMPILER) MESSAGE(STATUS "makeindex command MAKEINDEX_COMPILER not found but usually required.") ENDIF (NOT MAKEINDEX_COMPILER) IF (NOT DVIPS_CONVERTER) MESSAGE(STATUS "dvips command DVIPS_CONVERTER not found but usually required.") ENDIF (NOT DVIPS_CONVERTER) IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in") MESSAGE(STATUS "configured ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in --> ${CMAKE_CURRENT_BINARY_DIR}/doxy.config") CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in ${CMAKE_CURRENT_BINARY_DIR}/doxy.config @ONLY ) # use (configured) doxy.config from (out of place) BUILD tree: SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config") ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in") # use static hand-edited doxy.config from SOURCE tree: SET(DOXY_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config") IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config") MESSAGE(STATUS "WARNING: using existing ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config instead of configuring from doxy.config.in file.") ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config") IF (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in") # using template doxy.config.in MESSAGE(STATUS "configured ${CMAKE_CMAKE_MODULE_PATH}/doxy.config.in --> ${CMAKE_CURRENT_BINARY_DIR}/doxy.config") CONFIGURE_FILE(${CMAKE_MODULE_PATH}/doxy.config.in ${CMAKE_CURRENT_BINARY_DIR}/doxy.config @ONLY ) SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config") ELSE (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in") # failed completely... MESSAGE(SEND_ERROR "Please create ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in (or doxy.config as fallback)") ENDIF(EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in") ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config") ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in") ADD_CUSTOM_TARGET(doc ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG}) # create a windows help .chm file using hhc.exe # HTMLHelp DLL must be in path! # fallback: use hhw.exe interactively IF (WIN32) FIND_PACKAGE(HTMLHelp) IF (HTML_HELP_COMPILER) SET (TMP "${CMAKE_CURRENT_BINARY_DIR}\\Doc\\html\\index.hhp") STRING(REGEX REPLACE "[/]" "\\\\" HHP_FILE ${TMP} ) # MESSAGE(SEND_ERROR "DBG HHP_FILE=${HHP_FILE}") ADD_CUSTOM_TARGET(winhelp ${HTML_HELP_COMPILER} ${HHP_FILE}) ADD_DEPENDENCIES (winhelp doc) IF (NOT TARGET_DOC_SKIP_INSTALL) # install windows help? # determine useful name for output file # should be project and version unique to allow installing # multiple projects into one global directory IF (EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm") IF (PROJECT_NAME) SET(OUT "${PROJECT_NAME}") ELSE (PROJECT_NAME) SET(OUT "Documentation") # default ENDIF(PROJECT_NAME) IF (${PROJECT_NAME}_VERSION_MAJOR) SET(OUT "${OUT}-${${PROJECT_NAME}_VERSION_MAJOR}") IF (${PROJECT_NAME}_VERSION_MINOR) SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_MINOR}") IF (${PROJECT_NAME}_VERSION_PATCH) SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_PATCH}") ENDIF(${PROJECT_NAME}_VERSION_PATCH) ENDIF(${PROJECT_NAME}_VERSION_MINOR) ENDIF(${PROJECT_NAME}_VERSION_MAJOR) # keep suffix SET(OUT "${OUT}.chm") #MESSAGE("DBG ${PROJECT_BINARY_DIR}/Doc/html/index.chm \n${OUT}") # create target used by install and package commands INSTALL(FILES "${PROJECT_BINARY_DIR}/Doc/html/index.chm" DESTINATION "doc" RENAME "${OUT}" ) ENDIF(EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm") ENDIF(NOT TARGET_DOC_SKIP_INSTALL) ENDIF(HTML_HELP_COMPILER) # MESSAGE(SEND_ERROR "HTML_HELP_COMPILER=${HTML_HELP_COMPILER}") ENDIF (WIN32) ENDIF(DOXYGEN_FOUND) ebook-tools-0.2.2/cmake/FindPackageHandleStandardArgs.cmake0000644000530500000060000000455212021410400023356 0ustar elylevysystem# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (DEFAULT_MSG|"Custom failure message") VAR1 ... ) # This macro is intended to be used in FindXXX.cmake modules files. # It handles the REQUIRED and QUIET argument to FIND_PACKAGE() and # it also sets the _FOUND variable. # The package is found if all variables listed are TRUE. # Example: # # FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) # # LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and # LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE. # If it is not found and REQUIRED was used, it fails with FATAL_ERROR, # independent whether QUIET was used or not. # If it is found, the location is reported using the VAR1 argument, so # here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out. # If the second argument is DEFAULT_MSG, the message in the failure case will # be "Could NOT find LibXml2", if you don't like this message you can specify # your own custom failure message there. MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") IF (${_NAME}_FIND_REQUIRED) SET(_FAIL_MESSAGE "Could not find REQUIRED package ${_NAME}") ELSE (${_NAME}_FIND_REQUIRED) SET(_FAIL_MESSAGE "Could not find OPTIONAL package ${_NAME}") ENDIF (${_NAME}_FIND_REQUIRED) ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") SET(_FAIL_MESSAGE "${_FAIL_MSG}") ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") STRING(TOUPPER ${_NAME} _NAME_UPPER) SET(${_NAME_UPPER}_FOUND TRUE) IF(NOT ${_VAR1}) SET(${_NAME_UPPER}_FOUND FALSE) ENDIF(NOT ${_VAR1}) FOREACH(_CURRENT_VAR ${ARGN}) IF(NOT ${_CURRENT_VAR}) SET(${_NAME_UPPER}_FOUND FALSE) ENDIF(NOT ${_CURRENT_VAR}) ENDFOREACH(_CURRENT_VAR) IF (${_NAME_UPPER}_FOUND) IF (NOT ${_NAME}_FIND_QUIETLY) MESSAGE(STATUS "Found ${_NAME}: ${${_VAR1}}") ENDIF (NOT ${_NAME}_FIND_QUIETLY) ELSE (${_NAME_UPPER}_FOUND) IF (${_NAME}_FIND_REQUIRED) MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}") ELSE (${_NAME}_FIND_REQUIRED) IF (NOT ${_NAME}_FIND_QUIETLY) MESSAGE(STATUS "${_FAIL_MESSAGE}") ENDIF (NOT ${_NAME}_FIND_QUIETLY) ENDIF (${_NAME}_FIND_REQUIRED) ENDIF (${_NAME_UPPER}_FOUND) ENDMACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS) ebook-tools-0.2.2/TODO0000644000530500000060000000005412021410400014207 0ustar elylevysystemadd params to einfo OPS - finish up parsing