From: <svn...@op...> - 2009-03-29 14:14:54
|
Author: bricks Date: Sun Mar 29 16:14:48 2009 New Revision: 5421 URL: http://www.opensync.org/changeset/5421 Log: changed list pattern for all format related interfaces refs #975 Added: trunk/opensync/format/opensync_converter_internals.h Modified: trunk/opensync.sym trunk/opensync/engine/opensync_mapping_entry_engine.c trunk/opensync/format/opensync_converter.c trunk/opensync/format/opensync_converter.h trunk/opensync/format/opensync_format_env.c trunk/opensync/format/opensync_format_env.h trunk/opensync/format/opensync_format_env_internals.h trunk/tests/format-tests/check_conv.c trunk/tests/format-tests/check_converter.c Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync.sym Sun Mar 29 16:14:48 2009 (r5421) @@ -62,9 +62,8 @@ osync_converter_new_detector osync_converter_path_add_edge osync_converter_path_get_config +osync_converter_path_get_edges osync_converter_path_new -osync_converter_path_nth_edge -osync_converter_path_num_edges osync_converter_path_ref osync_converter_path_set_config osync_converter_path_unref @@ -149,12 +148,10 @@ osync_format_env_find_path_formats osync_format_env_find_path_formats_with_detectors osync_format_env_find_path_with_detectors +osync_format_env_get_converters +osync_format_env_get_objformats osync_format_env_load_plugins osync_format_env_new -osync_format_env_nth_converter -osync_format_env_nth_objformat -osync_format_env_num_converters -osync_format_env_num_objformats osync_format_env_ref osync_format_env_register_converter osync_format_env_register_objformat Modified: trunk/opensync/engine/opensync_mapping_entry_engine.c ============================================================================== --- trunk/opensync/engine/opensync_mapping_entry_engine.c Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/engine/opensync_mapping_entry_engine.c Sun Mar 29 16:14:48 2009 (r5421) @@ -30,6 +30,7 @@ #include "archive/opensync_archive_internals.h" #include "format/opensync_objformat_internals.h" +#include "format/opensync_converter_internals.h" #include "opensync_obj_engine.h" #include "opensync_obj_engine.h" Modified: trunk/opensync/format/opensync_converter.c ============================================================================== --- trunk/opensync/format/opensync_converter.c Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/format/opensync_converter.c Sun Mar 29 16:14:48 2009 (r5421) @@ -28,6 +28,7 @@ #include "format/opensync_objformat_internals.h" #include "opensync_converter_private.h" +#include "opensync_converter_internals.h" OSyncFormatConverter *osync_converter_new(OSyncConverterType type, OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat, OSyncFormatConvertFunc convert_func, OSyncError **error) { @@ -339,3 +340,7 @@ } } +OSyncList *osync_converter_path_get_edges(OSyncFormatConverterPath *path) { + return osync_list_copy(path->converters); +} + Modified: trunk/opensync/format/opensync_converter.h ============================================================================== --- trunk/opensync/format/opensync_converter.h Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/format/opensync_converter.h Sun Mar 29 16:14:48 2009 (r5421) @@ -68,14 +68,14 @@ */ OSYNC_EXPORT OSyncFormatConverter *osync_converter_new_detector(OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat, OSyncFormatDetectFunc detect_func, OSyncError **error); -/*! @brief Increase the reference count on a converter +/** @brief Increase the reference count on a converter * * @param converter Pointer to the converter * */ OSYNC_EXPORT OSyncFormatConverter *osync_converter_ref(OSyncFormatConverter *converter); -/*! @brief Decrease the reference count on a converter +/** @brief Decrease the reference count on a converter * * @param converter Pointer to the converter * @@ -158,26 +158,13 @@ */ OSYNC_EXPORT void osync_converter_path_add_edge(OSyncFormatConverterPath *path, OSyncFormatConverter *edge); -/** @brief Returns the number of converters in a converter path - * @param path Pointer to the converter path - * @returns the number of converters in the specified path - */ -OSYNC_EXPORT unsigned int osync_converter_path_num_edges(OSyncFormatConverterPath *path); - -/** @brief Returns the nth converter in a converter path - * @param path Pointer to the converter path - * @param nth The position of the converter to retrieve - * @returns the converter at the specified index - */ -OSYNC_EXPORT OSyncFormatConverter *osync_converter_path_nth_edge(OSyncFormatConverterPath *path, unsigned int nth); - /** @brief Returns configuration for converter path * @param path Pointer to the converter path * @returns The converter path configuration */ OSYNC_EXPORT const char *osync_converter_path_get_config(OSyncFormatConverterPath *path); -/*! @brief Sets the configuration for converter path +/** @brief Sets the configuration for converter path * @param path Pointer to the converter path * @param config The converter path configuration */ @@ -215,6 +202,13 @@ */ OSYNC_EXPORT void osync_converter_finalize(OSyncFormatConverter *converter); +/** + * @brief Returns a OSyncList of the format converters in this path + * @param path Pointer to the OSyncFormatConverterPath + * @return a shallow copy of the OSyncFormatConverter in the conversion path + */ +OSYNC_EXPORT OSyncList *osync_converter_path_get_edges(OSyncFormatConverterPath *path); + /*@}*/ #endif //_OPENSYNC_CONVERTER_H_ Added: trunk/opensync/format/opensync_converter_internals.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/opensync/format/opensync_converter_internals.h Sun Mar 29 16:14:48 2009 (r5421) @@ -0,0 +1,38 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_CONVERTER_INTERNALS_H_ +#define _OPENSYNC_CONVERTER_INTERNALS_H_ + +/** @brief Returns the number of converters in a converter path + * @param path Pointer to the converter path + * @returns the number of converters in the specified path + */ +OSYNC_TEST_EXPORT unsigned int osync_converter_path_num_edges(OSyncFormatConverterPath *path); + +/** @brief Returns the nth converter in a converter path + * @param path Pointer to the converter path + * @param nth The position of the converter to retrieve + * @returns the converter at the specified index + */ +OSYNC_TEST_EXPORT OSyncFormatConverter *osync_converter_path_nth_edge(OSyncFormatConverterPath *path, unsigned int nth); + + +#endif /* _OPENSYNC_CONVERTER_INTERNALS_H_ */ Modified: trunk/opensync/format/opensync_format_env.c ============================================================================== --- trunk/opensync/format/opensync_format_env.c Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/format/opensync_format_env.c Sun Mar 29 16:14:48 2009 (r5421) @@ -32,6 +32,8 @@ #include "opensync_format_env_internals.h" #include "opensync_format_env_private.h" +#include "opensync_converter_internals.h" + static osync_bool osync_format_env_load_modules(OSyncFormatEnv *env, const char *path, osync_bool must_exist, OSyncError **error) @@ -847,6 +849,10 @@ return osync_list_nth_data(env->objformats, nth); } +OSyncList *osync_format_env_get_objformats(OSyncFormatEnv *env) { + return osync_list_copy(env->objformats); +} + void osync_format_env_register_converter(OSyncFormatEnv *env, OSyncFormatConverter *converter) { osync_assert(env); @@ -912,7 +918,7 @@ return r; } -int osync_format_env_num_converters(OSyncFormatEnv *env) +unsigned int osync_format_env_num_converters(OSyncFormatEnv *env) { osync_assert(env); return osync_list_length(env->converters); @@ -924,6 +930,10 @@ return osync_list_nth_data(env->converters, nth); } +OSyncList *osync_format_env_get_converters(OSyncFormatEnv *env) { + return osync_list_copy(env->converters); +} + void osync_format_env_register_filter(OSyncFormatEnv *env, OSyncCustomFilter *filter) { osync_assert(env); Modified: trunk/opensync/format/opensync_format_env.h ============================================================================== --- trunk/opensync/format/opensync_format_env.h Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/format/opensync_format_env.h Sun Mar 29 16:14:48 2009 (r5421) @@ -100,22 +100,16 @@ */ OSYNC_EXPORT OSyncObjFormat *osync_format_env_find_objformat(OSyncFormatEnv *env, const char *name); -/** @brief Returns the number of available object formats +/** + * @brief Return a OSyncList of all formats which are store inside this format environment * - * @param env The format environment - * @returns The number of object formats - * - */ -OSYNC_EXPORT unsigned int osync_format_env_num_objformats(OSyncFormatEnv *env); - -/** @brief Gets the nth object format - * - * @param env The format environment - * @param nth The position of the object format to retrieve - * @returns The object format + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. * + * @param A pointer to a OSyncFormatEnv + * @return a shallow copy of all OSyncObjFormats stored in the format env */ -OSYNC_EXPORT OSyncObjFormat *osync_format_env_nth_objformat(OSyncFormatEnv *env, unsigned int nth); +OSYNC_EXPORT OSyncList *osync_format_env_get_objformats(OSyncFormatEnv *env); /** @brief Registers Format Converter or Detector to Format Environment * @@ -147,22 +141,16 @@ */ OSYNC_EXPORT OSyncList *osync_format_env_find_converters(OSyncFormatEnv *env, OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat); -/** @brief Returns the number of available converters +/** + * @brief Return a OSyncList of all converters which are store in this format environment * - * @param env The format environment - * @returns The number of converters - * - */ -OSYNC_EXPORT int osync_format_env_num_converters(OSyncFormatEnv *env); - -/** @brief Gets the nth format converter - * - * @param env The format environment - * @param nth The position of the format converter to retrieve - * @returns The format converter + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. * + * @param A pointer to a OSyncFormatEnv + * @return a shallow copy of all OSyncFormatConverters stored in the format env */ -OSYNC_EXPORT OSyncFormatConverter *osync_format_env_nth_converter(OSyncFormatEnv *env, int nth); +OSYNC_EXPORT OSyncList *osync_format_env_get_converters(OSyncFormatEnv *env); /** @brief Tries to detect the format of the given data object * Modified: trunk/opensync/format/opensync_format_env_internals.h ============================================================================== --- trunk/opensync/format/opensync_format_env_internals.h Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/format/opensync_format_env_internals.h Sun Mar 29 16:14:48 2009 (r5421) @@ -37,7 +37,7 @@ osync_bool osync_conv_convert_fn(OSyncFormatEnv *env, OSyncChange *change, OSyncPathTargetFn target_fn, const void *fndata, const char *extension_name, OSyncError **error); osync_bool osync_conv_convert_fmtlist(OSyncFormatEnv *env, OSyncChange *change, GList/*OSyncObjFormat * */ *targets); -/*! @brief The environment used for conversions +/** @brief The environment used for conversions */ struct OSyncFormatEnv { /** A List of formats */ @@ -53,7 +53,7 @@ int ref_count; }; -/*! @brief search tree for format converters +/** @brief search tree for format converters */ typedef struct OSyncFormatConverterTree { /* The converters that weren't reached yet */ @@ -125,6 +125,41 @@ */ OSYNC_TEST_EXPORT void osync_format_env_objformat_finalize(OSyncFormatEnv *env); +/** @brief Returns the number of available object formats + * + * @param env The format environment + * @returns The number of object formats + * + */ +OSYNC_TEST_EXPORT unsigned int osync_format_env_num_objformats(OSyncFormatEnv *env); + +/** @brief Gets the nth object format + * + * @param env The format environment + * @param nth The position of the object format to retrieve + * @returns The object format + * + */ +OSYNC_TEST_EXPORT OSyncObjFormat *osync_format_env_nth_objformat(OSyncFormatEnv *env, unsigned int nth); + +/** @brief Returns the number of available converters + * + * @param env The format environment + * @returns The number of converters + * + */ +OSYNC_TEST_EXPORT unsigned int osync_format_env_num_converters(OSyncFormatEnv *env); + +/** @brief Gets the nth format converter + * + * @param env The format environment + * @param nth The position of the format converter to retrieve + * @returns The format converter + * + */ +OSYNC_TEST_EXPORT OSyncFormatConverter *osync_format_env_nth_converter(OSyncFormatEnv *env, int nth); + + /*@}*/ #endif /* _OPENSYNC_FORMAT_ENV_INTERNALS_H_ */ Modified: trunk/tests/format-tests/check_conv.c ============================================================================== --- trunk/tests/format-tests/check_conv.c Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/tests/format-tests/check_conv.c Sun Mar 29 16:14:48 2009 (r5421) @@ -3,6 +3,7 @@ #include <opensync/opensync-format.h> #include "opensync/format/opensync_filter_internals.h" #include "opensync/format/opensync_format_env_internals.h" +#include "opensync/format/opensync_converter_internals.h" START_TEST (conv_env_create) { Modified: trunk/tests/format-tests/check_converter.c ============================================================================== --- trunk/tests/format-tests/check_converter.c Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/tests/format-tests/check_converter.c Sun Mar 29 16:14:48 2009 (r5421) @@ -3,6 +3,8 @@ #include <opensync/opensync-data.h> #include <opensync/opensync-format.h> +#include "opensync/format/opensync_converter_internals.h" + osync_bool converter_conv(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) { return TRUE; |