diff --git a/trunk/CMakeLists.txt b/trunk/CMakeLists.txt index 69c0400..3f1333a 100644 --- a/trunk/CMakeLists.txt +++ b/trunk/CMakeLists.txt @@ -1,93 +1,94 @@ cmake_minimum_required(VERSION 2.8) project(xmount C) include(CheckIncludeFiles) #include(CheckCSourceCompiles) # Only for internal packaging #set(STATIC_EWF 1) #set(STATIC_AFF 1) if(APPLE) # On OSx, do not try to find frameworks but only std headers / libraries set(CMAKE_FIND_FRAMEWORK "NEVER") endif(APPLE) # Make sure CMAKE_BUILD_TYPE is set if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") else(NOT CMAKE_BUILD_TYPE) if(NOT (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "Debug")) message(FATAL_ERROR "Only build types 'Release' and 'Debug' are supported!") endif(NOT (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "Debug")) endif(NOT CMAKE_BUILD_TYPE) # Add cmake_modules dir to CMAKE_MODULE_PATH set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/") # Check required headers check_include_files(stdlib.h HAVE_STDLIB_H) check_include_files(stdio.h HAVE_STDIO_H) check_include_files(stdint.h HAVE_STDINT_H) check_include_files(stdarg.h HAVE_STDARG_H) check_include_files(string.h HAVE_STRING_H) check_include_files(errno.h HAVE_ERRNO_H) check_include_files(fcntl.h HAVE_FCNTL_H) check_include_files(dlfcn.h HAVE_DLFCN_H) check_include_files(dirent.h HAVE_DIRENT_H) check_include_files(unistd.h HAVE_UNISTD_H) check_include_files(sys/ioctl.h HAVE_SYS_IOCTL_H) check_include_files(sys/stat.h HAVE_SYS_STAT_H) check_include_files(sys/types.h HAVE_SYS_TYPES_H) check_include_files(linux/fs.h HAVE_LINUX_FS_H) check_include_files(grp.h HAVE_GRP_H) check_include_files(pwd.h HAVE_PWD_H) check_include_files(pthread.h HAVE_PTHREAD_H) check_include_files(time.h HAVE_TIME_H) check_include_files(inttypes.h HAVE_INTTYPES_H) check_include_files(byteswap.h HAVE_BYTESWAP_H) check_include_files(endian.h HAVE_ENDIAN_H) check_include_files(libkern/OSByteOrder.h HAVE_LIBKERN_OSBYTEORDER_H) # Check for required libs if(NOT APPLE) find_package(LibFUSE REQUIRED) else(NOT APPLE) # On OSx, search for osxfuse find_package(LibOSXFUSE REQUIRED) endif(NOT APPLE) # Generate config.h and add it's path to the include dirs configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) # Add preprocessor definitions add_definitions(-D_LARGEFILE64_SOURCE) add_definitions(-D_FILE_OFFSET_BITS=64) add_definitions(-D_GNU_SOURCE) set(CMAKE_C_FLAGS "-fno-strict-aliasing -std=c99 -Wall") set(CMAKE_C_FLAGS_RELEASE "-O2 ${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS_DEBUG "-ggdb -O0 ${CMAKE_C_FLAGS}") # Check that off_t can represent 2**63 - 1 correctly. # If it can't, we need to set _FILE_OFFSET_BITS=64 #check_c_source_compiles(" # #include # #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) # int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; # int main() { return 0; } #" _OFFT_IS_64BIT) #if(NOT ${_OFFT_IS_64BIT}) # set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-D_FILE_OFFSET_BITS=64") #endif(NOT ${_OFFT_IS_64BIT}) # Compile stuff in sub dirs add_subdirectory(libxmount_input) +add_subdirectory(libxmount_morphing) add_subdirectory(src) # Install man page INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/xmount.1 DESTINATION share/man/man1) diff --git a/trunk/libxmount_input/libxmount_input.h b/trunk/libxmount_input/libxmount_input.h index a2d3164..15e44a4 100644 --- a/trunk/libxmount_input/libxmount_input.h +++ b/trunk/libxmount_input/libxmount_input.h @@ -1,206 +1,223 @@ /******************************************************************************* * xmount Copyright (c) 2008-2014 by Gillen Daniel * * * * This program is free software: you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the Free * * Software Foundation, either version 3 of the License, or (at your option) * * any later version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT * * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * * more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * *******************************************************************************/ #ifndef LIBXMOUNT_INPUT_H #define LIBXMOUNT_INPUT_H #define LIBXMOUNT_INPUT_API_VERSION 1 #include #include // For int*_t and uint*_t #include // For PRI* //! Structure containing pointers to the lib's functions typedef struct s_LibXmountInputFunctions { //! Function to initialize handle /*! * This function is called once to allow the lib to alloc any needed * structures before other functions that rely upon a valid handle are called * (for ex. OptionsParse or Open). * + * The p_format parameter specifies one of the formats returned by + * LibXmount_Input_GetSupportedFormats() which should be used for this handle. + * * \param pp_handle Pointer to store handle to + * \param p_format Input image format * \return 0 on success or error code */ - int (*CreateHandle)(void **pp_handle); + int (*CreateHandle)(void **pp_handle, char *p_format); //! Function to destroy handle /*! * In this function, any structures allocated with CreateHandle should be * freed. It is generally the last function called before unloading of lib * happens. * * By convention, after this function has been called, *pp_handle must be * NULL. * * \param pp_handle Pointer to store handle to * \return 0 on success or error code */ int (*DestroyHandle)(void **pp_handle); - //! Function to open input image + //! Function to open input image(s) /*! - * Opens the specified image for reading. + * Opens the specified image(s) for reading. * * \param pp_handle Pointer to store handle of opened image to * \param pp_filename_arr Array containing all specified input images * \param filename_arr_len Length of pp_filename_arr * \return 0 on success or error code */ int (*Open)(void **pp_handle, const char **pp_filename_arr, uint64_t filename_arr_len); - //! Function to close an opened input image + //! Function to close opened input image(s) /*! - * Closes the input image and frees any memory allocaed during opening but - * does not invalidate the main handle. Further calls to for ex. Open must + * Closes all input images and frees any memory allocaed during opening but + * does not invalidate the main handle. Further calls to for ex. Open() must * be possible without first calling CreateHandle again! * * \param pp_handle Pointer to the handle of the opened image * \return 0 on success or error code */ int (*Close)(void **pp_handle); - //! Function to get the input image's size + //! Function to get the amount of opened images + /*! + * \param p_handle Handle to the opened image + * \param p_count Pointer to store the image count to + * \return 0 on success or error code + */ + int (*ImageCount)(void *p_handle, + uint64_t *p_count); + + //! Function to get an input image's size /*! - * Returns the real size of the input image. Real means the size of the - * uncompressed or otherwise made available data contained inside the input - * image. + * Returns the real size of the specified input image. Real means the size of + * the uncompressed or otherwise made available data contained inside the + * input image. * * \param p_handle Handle to the opened image + * \param image Image number for which size is requested (0 = first image) * \param p_size Pointer to store input image's size to * \return 0 on success or error code */ int (*Size)(void *p_handle, + uint64_t image, uint64_t *p_size); - //! Function to read data from input image + //! Function to read data from an input image /*! * Reads count bytes at offset from input image and copies them into memory * starting at the address of p_buf. Memory is pre-allocated to as much bytes * as should be read. * * \param p_handle Handle to the opened image + * \param image Image number for which data is requested (0 = first image) * \param offset Position at which to start reading * \param p_buf Buffer to store read data to * \param count Amount of bytes to read * \return 0 on success or error code */ int (*Read)(void *p_handle, + uint64_t image, uint64_t offset, char *p_buf, uint32_t count); //! Function to get a help message for any supported lib-specific options /*! * Calling this function should return a string containing help messages for * any supported lib-specific options. Every line of this text must be * prepended with 6 spaces. * * Returned string must be constant. It won't be freed! * * If there is no help text, this function must return NULL. * * \return Pointer to a null-terminated string containing the help text */ const char* (*OptionsHelp)(); //! Function to parse any lib-specific options /*! * This function is called with the options given with the --inopts parameter. * All contained options are for the lib. If errors or unknown options are * found, this function should fail and return an error message in pp_error. * pp_error will be freed by the caller by using FreeBuffer. * * \param p_handle Handle to the opened image * \param p_options String with specified options * \param pp_error Pointer to a string with error message * \return 0 on success or error code and error message */ int (*OptionsParse)(void *p_handle, char *p_options, char **pp_error); //! Function to get content to add to the info file /*! * The returned string is added to xmount's info file. This function is only * called once when the info file is generated. The returned string is then * freed with a call to FreeBuffer. * * \param p_handle Handle to the opened image * \param pp_info_buf Pointer to store the null-terminated content * \return 0 on success or error code */ int (*GetInfofileContent)(void *p_handle, char **pp_info_buf); //! Function to get an error message /*! * This function should translate an error code that was previously returned * by one of the library functions into a human readable error message. * * By convention, this function must always return a valid pointer to a * NULL-terminated string! * * \param err_num Error code as returned by lib */ const char* (*GetErrorMessage)(int err_num); //! Function to free buffers that were allocated by lib /*! * \param p_buf Buffer to free */ void (*FreeBuffer)(void *p_buf); } ts_LibXmountInputFunctions, *pts_LibXmountInputFunctions; //! Get library API version /*! * This function should return the value of LIBXMOUNT_INPUT_API_VERSION * * \return Supported version */ uint8_t LibXmount_Input_GetApiVersion(); typedef uint8_t (*t_LibXmount_Input_GetApiVersion)(); //! Get a list of supported formats /*! * Gets a list of supported input image formats. These are the strings * specified with xmount's --in command line option. The returned * string must be a constant list of image formats split by \0 chars. To mark * the end of the string, a single \0 must be used. * * As an example, "first\0second\0\0" would be a correct string to return for * a lib supporting two input image formats. * * \return List containing supported format strings */ const char* LibXmount_Input_GetSupportedFormats(); typedef const char* (*t_LibXmount_Input_GetSupportedFormats)(); //! Get the lib's s_LibXmountInputFunctions structure /*! * This function should set the members of the given s_LibXmountInputFunctions * structure to the internal lib functions. All members have to be set. * * \param p_functions s_LibXmountInputFunctions structure to fill */ void LibXmount_Input_GetFunctions(pts_LibXmountInputFunctions p_functions); typedef void (*t_LibXmount_Input_GetFunctions)(pts_LibXmountInputFunctions); #endif // LIBXMOUNT_INPUT_H diff --git a/trunk/libxmount_morphing/CMakeLists.txt b/trunk/libxmount_morphing/CMakeLists.txt new file mode 100644 index 0000000..1be81e7 --- /dev/null +++ b/trunk/libxmount_morphing/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(libxmount_morphing_combine) +#add_subdirectory(libxmount_morphing_stripe) + diff --git a/trunk/libxmount_input/libxmount_input.h b/trunk/libxmount_morphing/libxmount_morphing.h similarity index 68% copy from trunk/libxmount_input/libxmount_input.h copy to trunk/libxmount_morphing/libxmount_morphing.h index a2d3164..7a1986f 100644 --- a/trunk/libxmount_input/libxmount_input.h +++ b/trunk/libxmount_morphing/libxmount_morphing.h @@ -1,206 +1,198 @@ /******************************************************************************* * xmount Copyright (c) 2008-2014 by Gillen Daniel * * * * This program is free software: you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the Free * * Software Foundation, either version 3 of the License, or (at your option) * * any later version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT * * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * * more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * *******************************************************************************/ -#ifndef LIBXMOUNT_INPUT_H -#define LIBXMOUNT_INPUT_H +#ifndef LIBXMOUNT_MORPHING_H +#define LIBXMOUNT_MORPHING_H -#define LIBXMOUNT_INPUT_API_VERSION 1 +#define LIBXMOUNT_MORPHING_API_VERSION 1 #include #include // For int*_t and uint*_t #include // For PRI* +#include "../libxmount_input/libxmount_input.h" + //! Structure containing pointers to the lib's functions -typedef struct s_LibXmountInputFunctions { +typedef struct s_LibXmountMorphingFunctions { //! Function to initialize handle /*! * This function is called once to allow the lib to alloc any needed * structures before other functions that rely upon a valid handle are called - * (for ex. OptionsParse or Open). + * (for ex. OptionsParse or Morph). + * + * The p_format parameter specifies one of the morphing functions returned by + * LibXmount_Morphing_GetSupportedMorphFunctions() which should be used for + * this handle. * * \param pp_handle Pointer to store handle to + * \param p_morph_function Morph function to use * \return 0 on success or error code */ - int (*CreateHandle)(void **pp_handle); + int (*CreateHandle)(void **pp_handle, char *p_morph_function); //! Function to destroy handle /*! * In this function, any structures allocated with CreateHandle should be * freed. It is generally the last function called before unloading of lib * happens. * * By convention, after this function has been called, *pp_handle must be * NULL. * * \param pp_handle Pointer to store handle to * \return 0 on success or error code */ int (*DestroyHandle)(void **pp_handle); - //! Function to open input image + //! Function to start morphing /*! - * Opens the specified image for reading. + * Begins to morph input image * - * \param pp_handle Pointer to store handle of opened image to - * \param pp_filename_arr Array containing all specified input images - * \param filename_arr_len Length of pp_filename_arr + * \param p_handle Handle + * \param p_input_functions ts_LibXmountInputFunctions structure * \return 0 on success or error code */ - int (*Open)(void **pp_handle, - const char **pp_filename_arr, - uint64_t filename_arr_len); + int (*Morph)(void *p_handle, + pts_LibXmountInputFunctions p_input_functions); - //! Function to close an opened input image + //! Function to get the size of the morphed data /*! - * Closes the input image and frees any memory allocaed during opening but - * does not invalidate the main handle. Further calls to for ex. Open must - * be possible without first calling CreateHandle again! - * - * \param pp_handle Pointer to the handle of the opened image - * \return 0 on success or error code - */ - int (*Close)(void **pp_handle); - - //! Function to get the input image's size - /*! - * Returns the real size of the input image. Real means the size of the - * uncompressed or otherwise made available data contained inside the input - * image. - * * \param p_handle Handle to the opened image * \param p_size Pointer to store input image's size to * \return 0 on success or error code */ int (*Size)(void *p_handle, uint64_t *p_size); - //! Function to read data from input image + //! Function to read data from an input image /*! * Reads count bytes at offset from input image and copies them into memory * starting at the address of p_buf. Memory is pre-allocated to as much bytes * as should be read. * * \param p_handle Handle to the opened image * \param offset Position at which to start reading * \param p_buf Buffer to store read data to * \param count Amount of bytes to read * \return 0 on success or error code */ int (*Read)(void *p_handle, uint64_t offset, char *p_buf, uint32_t count); //! Function to get a help message for any supported lib-specific options /*! * Calling this function should return a string containing help messages for * any supported lib-specific options. Every line of this text must be * prepended with 6 spaces. * * Returned string must be constant. It won't be freed! * * If there is no help text, this function must return NULL. * * \return Pointer to a null-terminated string containing the help text */ const char* (*OptionsHelp)(); //! Function to parse any lib-specific options /*! * This function is called with the options given with the --inopts parameter. * All contained options are for the lib. If errors or unknown options are * found, this function should fail and return an error message in pp_error. * pp_error will be freed by the caller by using FreeBuffer. * * \param p_handle Handle to the opened image * \param p_options String with specified options * \param pp_error Pointer to a string with error message * \return 0 on success or error code and error message */ int (*OptionsParse)(void *p_handle, char *p_options, char **pp_error); //! Function to get content to add to the info file /*! * The returned string is added to xmount's info file. This function is only * called once when the info file is generated. The returned string is then * freed with a call to FreeBuffer. * * \param p_handle Handle to the opened image * \param pp_info_buf Pointer to store the null-terminated content * \return 0 on success or error code */ int (*GetInfofileContent)(void *p_handle, char **pp_info_buf); //! Function to get an error message /*! * This function should translate an error code that was previously returned * by one of the library functions into a human readable error message. * * By convention, this function must always return a valid pointer to a * NULL-terminated string! * * \param err_num Error code as returned by lib */ const char* (*GetErrorMessage)(int err_num); //! Function to free buffers that were allocated by lib /*! * \param p_buf Buffer to free */ void (*FreeBuffer)(void *p_buf); -} ts_LibXmountInputFunctions, *pts_LibXmountInputFunctions; +} ts_LibXmountMorphingFunctions, *pts_LibXmountMorphingFunctions; //! Get library API version /*! - * This function should return the value of LIBXMOUNT_INPUT_API_VERSION + * This function should return the value of LIBXMOUNT_MORPHING_API_VERSION * * \return Supported version */ -uint8_t LibXmount_Input_GetApiVersion(); -typedef uint8_t (*t_LibXmount_Input_GetApiVersion)(); +uint8_t LibXmount_Morphing_GetApiVersion(); +typedef uint8_t (*t_LibXmount_Morphing_GetApiVersion)(); -//! Get a list of supported formats +//! Get a list of supported morphing functions /*! - * Gets a list of supported input image formats. These are the strings - * specified with xmount's --in command line option. The returned - * string must be a constant list of image formats split by \0 chars. To mark - * the end of the string, a single \0 must be used. + * Gets a list of supported morphing functions. These is the string + * specified with xmount's --morph command line option. The returned + * string must be a constant vector of morphing functions split by \0 chars. To + * mark the end of the vector, a single \0 must be used. * * As an example, "first\0second\0\0" would be a correct string to return for - * a lib supporting two input image formats. + * a lib supporting two morphing functions. * - * \return List containing supported format strings + * \return Vector containing supported morphing functions */ -const char* LibXmount_Input_GetSupportedFormats(); -typedef const char* (*t_LibXmount_Input_GetSupportedFormats)(); +const char* LibXmount_Morphing_GetSupportedMorphFunctions(); +typedef const char* (*t_LibXmount_Morphing_GetSupportedMorphFunctions)(); -//! Get the lib's s_LibXmountInputFunctions structure +//! Get the lib's s_LibXmountMorphingFunctions structure /*! - * This function should set the members of the given s_LibXmountInputFunctions - * structure to the internal lib functions. All members have to be set. + * This function should set the members of the given + * s_LibXmountMorphingFunctions structure to the internal lib functions. All + * members have to be set. * - * \param p_functions s_LibXmountInputFunctions structure to fill + * \param p_functions s_LibXmountMorphingFunctions structure to fill */ -void LibXmount_Input_GetFunctions(pts_LibXmountInputFunctions p_functions); -typedef void (*t_LibXmount_Input_GetFunctions)(pts_LibXmountInputFunctions); +void LibXmount_Morphing_GetFunctions(pts_LibXmountMorphingFunctions p_functions); +typedef void (*t_LibXmount_Morphing_GetFunctions)(pts_LibXmountMorphingFunctions); + -#endif // LIBXMOUNT_INPUT_H +#endif // LIBXMOUNT_MORPHING_H diff --git a/trunk/libxmount_morphing/libxmount_morphing_combine/CMakeLists.txt b/trunk/libxmount_morphing/libxmount_morphing_combine/CMakeLists.txt new file mode 100644 index 0000000..13a4222 --- /dev/null +++ b/trunk/libxmount_morphing/libxmount_morphing_combine/CMakeLists.txt @@ -0,0 +1,10 @@ +if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) # CMake 3.0 +endif(POLICY CMP0042) + +project(libxmount_morphing_combine C) + +add_library(xmount_morphing_combine SHARED libxmount_morphing_combine.c) + +install(TARGETS xmount_morphing_combine DESTINATION lib/xmount) + diff --git a/trunk/libxmount_morphing/libxmount_morphing_combine/libxmount_morphing_combine.c b/trunk/libxmount_morphing/libxmount_morphing_combine/libxmount_morphing_combine.c new file mode 100644 index 0000000..e69de29 diff --git a/trunk/libxmount_morphing/libxmount_morphing_combine/libxmount_morphing_combine.h b/trunk/libxmount_morphing/libxmount_morphing_combine/libxmount_morphing_combine.h new file mode 100644 index 0000000..e69de29 diff --git a/trunk/libxmount_morphing/libxmount_morphing_stripe/CMakeLists.txt b/trunk/libxmount_morphing/libxmount_morphing_stripe/CMakeLists.txt new file mode 100644 index 0000000..18df098 --- /dev/null +++ b/trunk/libxmount_morphing/libxmount_morphing_stripe/CMakeLists.txt @@ -0,0 +1,10 @@ +if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) # CMake 3.0 +endif(POLICY CMP0042) + +project(libxmount_morphing_stripe C) + +add_library(xmount_morphing_stripe SHARED libxmount_morphing_stripe.c) + +install(TARGETS xmount_morphing_stripe DESTINATION lib/xmount) + diff --git a/trunk/libxmount_morphing/libxmount_morphing_stripe/libxmount_morphing_stripe.c b/trunk/libxmount_morphing/libxmount_morphing_stripe/libxmount_morphing_stripe.c new file mode 100644 index 0000000..e69de29 diff --git a/trunk/libxmount_morphing/libxmount_morphing_stripe/libxmount_morphing_stripe.h b/trunk/libxmount_morphing/libxmount_morphing_stripe/libxmount_morphing_stripe.h new file mode 100644 index 0000000..e69de29