+++ /dev/null
-# - Try to find Iconv
-# Once done this will define
-#
-# ICONV_FOUND - system has Iconv
-# ICONV_INCLUDE_DIRS - the Iconv include directory
-# ICONV_LIBRARIES - Link these to use Iconv
-# ICONV_DEFINITIONS - Compiler switches required for using Iconv
-#
-# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
-#
-# Redistribution and use is allowed according to the terms of the New
-# BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-#
-
-include(CheckIncludeFile)
-include(CheckFunctionExists)
-include(CheckLibraryExists)
-include(CheckPrototypeDefinition)
-
-find_path(ICONV_INCLUDE_DIR
- NAMES
- iconv.h sys/iconv.h
-)
-
-set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
-check_include_file(iconv.h HAVE_ICONV_H)
-check_include_file(sys/iconv.h HAVE_SYS_ICONV_H)
-set(CMAKE_REQUIRED_INCLUDES)
-
-find_library(ICONV_LIBRARY
- NAMES
- iconv
- libiconv
- PATHS
-)
-
-if (ICONV_LIBRARY)
- get_filename_component(_ICONV_NAME ${ICONV_LIBRARY} NAME)
- get_filename_component(_ICONV_PATH ${ICONV_LIBRARY} PATH)
- check_library_exists(${_ICONV_NAME} iconv ${_ICONV_PATH} HAVE_ICONV)
-else()
- check_function_exists(iconv HAVE_ICONV)
-endif()
-
-if (HAVE_ICONV_H OR HAVE_SYS_ICONV_H)
- if (HAVE_ICONV_H)
- set(_ICONV_PROTO_INCLUDE "iconv.h")
- endif (HAVE_ICONV_H)
- if (HAVE_SYS_ICONV_H)
- set(_ICONV_PROTO_INCLUDE "sys/iconv.h")
- endif (HAVE_SYS_ICONV_H)
-
- set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
- check_prototype_definition(iconv
- "size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)"
- "-1"
- ${_ICONV_PROTO_INCLUDE}
- HAVE_ICONV_CONST)
- set(CMAKE_REQUIRED_INCLUDES)
-endif (HAVE_ICONV_H OR HAVE_SYS_ICONV_H)
-
-set(ICONV_INCLUDE_DIRS
- ${ICONV_INCLUDE_DIR}
-)
-
-if (ICONV_LIBRARY)
- set(ICONV_LIBRARIES
- ${ICONV_LIBRARIES}
- ${ICONV_LIBRARY}
- )
-endif (ICONV_LIBRARY)
-
-include(FindPackageHandleStandardArgs)
-if (ICONV_LIBRARIES)
- find_package_handle_standard_args(Iconv DEFAULT_MSG ICONV_LIBRARIES ICONV_INCLUDE_DIRS)
-else()
- find_package_handle_standard_args(Iconv DEFAULT_MSG ICONV_INCLUDE_DIRS)
-endif()
-
-# show the ICONV_INCLUDE_DIRS and ICONV_LIBRARIES variables only in the advanced view
-mark_as_advanced(ICONV_INCLUDE_DIRS ICONV_LIBRARIES)
include(MacroAddPlugin)
include(MacroCopyFile)
-if (NOT WIN32)
- find_package(Iconv)
-endif (NOT WIN32)
-
find_package(SQLite3 3.8.0 REQUIRED)
include(ConfigureChecks.cmake)
-if ( NOT WIN32 )
- option(WITH_ICONV "Build csync with iconv support" ON)
-endif()
option(UNIT_TESTING "Build with unit tests" OFF)
option(MEM_NULL_TESTS "Enable NULL memory testing" OFF)
#cmakedefine HAVE_CLOCK_GETTIME
#cmakedefine WITH_LOG4C 1
-#cmakedefine WITH_ICONV 1
#cmakedefine HAVE_ARGP_H 1
-#cmakedefine HAVE_ICONV_H 1
-#cmakedefine HAVE_SYS_ICONV_H 1
#cmakedefine HAVE_TIMEGM 1
#cmakedefine HAVE_STRERROR_R 1
#cmakedefine HAVE_UTIMES 1
#cmakedefine HAVE_LSTAT 1
#cmakedefine HAVE_FNMATCH 1
-#cmakedefine HAVE_ICONV 1
-#cmakedefine HAVE_ICONV_CONST 1
#cmakedefine HAVE___MINGW_ASPRINTF 1
#cmakedefine HAVE_ASPRINTF 1
${SQLITE3_LIBRARIES}
)
-if(HAVE_ICONV AND WITH_ICONV)
- list(APPEND CSYNC_PRIVATE_INCLUDE_DIRS ${ICONV_INCLUDE_DIR})
- list(APPEND CSYNC_LINK_LIBRARIES ${ICONV_LIBRARIES})
-endif()
-
# Specific option for builds tied to servers that do not support renaming extensions
set(NO_RENAME_EXTENSION 0 CACHE BOOL "Do not issue rename if the extension changes")
if(NO_RENAME_EXTENSION)
#include <sys/types.h>
#include <stdbool.h>
-#ifdef HAVE_ICONV_H
-#include <iconv.h>
-#endif
-#ifdef HAVE_SYS_ICONV_H
-#include <sys/iconv.h>
-#endif
-
#include "c_lib.h"
#include "csync_private.h"
#include "csync_exclude.h"
SAFE_FREE(ctx->local.uri);
SAFE_FREE(ctx->error_string);
-#ifdef WITH_ICONV
- c_close_iconv();
-#endif
-
SAFE_FREE(ctx);
return rc;
return csync_vio_get_status_string(ctx);
}
-#ifdef WITH_ICONV
-int csync_set_iconv_codec(const char *from)
-{
- c_close_iconv();
-
- if (from != NULL) {
- c_setup_iconv(from);
- }
-
- return 0;
-}
-#endif
-
void csync_request_abort(CSYNC *ctx)
{
if (ctx != NULL) {
*/
const char OCSYNC_EXPORT *csync_get_status_string(CSYNC *ctx);
-#ifdef WITH_ICONV
-/**
- * @brief Set iconv source codec for filenames.
- *
- * @param from Source codec.
- *
- * @return 0 on success, or an iconv error number.
- */
-int OCSYNC_EXPORT csync_set_iconv_codec(const char *from);
-#endif
-
/**
* @brief Aborts the current sync run as soon as possible. Can be called from another thread.
*
#include "csync.h"
#include "csync_misc.h"
-#ifdef WITH_ICONV
-#include <iconv.h>
-#endif
-
-#ifdef HAVE_ICONV_H
-#include <iconv.h>
-#endif
-#ifdef HAVE_SYS_ICONV_H
-#include <sys/iconv.h>
-#endif
-
#include "csync_macros.h"
/**
} remote;
-#if defined(HAVE_ICONV) && defined(WITH_ICONV)
- struct {
- iconv_t iconv_cd;
- } options;
-#endif
-
/* replica we are currently walking */
enum csync_replica_e current;
CACHE INTERNAL "cstdlib public include directories"
)
-set(CSTDLIB_PRIVATE_INCLUDE_DIRS
- ${ICONV_INCLUDE_DIR}
-)
-
set(CSTDLIB_LIBRARY
cstdlib
CACHE INTERNAL "cstdlib library"
include_directories(
${CSTDLIB_PUBLIC_INCLUDE_DIRS}
- ${CSTDLIB_PRIVATE_INCLUDE_DIRS}
)
add_library(${CSTDLIB_LIBRARY} STATIC ${cstdlib_SRCS})
#define _tgetcwd getcwd
#endif
-#ifdef WITH_ICONV
-/** @internal */
-int c_setup_iconv(const char* to);
-/** @internal */
-int c_close_iconv(void);
-#endif
-
/* FIXME: Implement TLS for OS X */
#if defined(__GNUC__) && !defined(__APPLE__)
# define CSYNC_THREAD __thread
#include <windows.h>
#endif
-#if defined(HAVE_ICONV) && defined(WITH_ICONV)
-# ifdef HAVE_ICONV_H
-# include <iconv.h>
-# endif
-# ifdef HAVE_SYS_ICONV_H
-# include <sys/iconv.h>
-# endif
-
-typedef struct {
- iconv_t to;
- iconv_t from;
-} iconv_conversions;
-
-CSYNC_THREAD iconv_conversions _iconvs = { NULL, NULL };
-
-int c_setup_iconv(const char* to) {
- _iconvs.to = iconv_open(to, "UTF-8");
- _iconvs.from = iconv_open("UTF-8", to);
-
- if (_iconvs.to == (iconv_t)-1 || _iconvs.from == (iconv_t)-1)
- return -1;
-
- return 0;
-}
-
-int c_close_iconv() {
- int ret_to = 0;
- int ret_from = 0;
- if( _iconvs.to != (iconv_t) NULL ) {
- ret_to = iconv_close(_iconvs.to);
- }
- if( _iconvs.from != (iconv_t) NULL ) {
- ret_from = iconv_close(_iconvs.from);
- }
-
- if (ret_to == -1 || ret_from == -1)
- return -1;
-
- _iconvs.to = (iconv_t) 0;
- _iconvs.from = (iconv_t) 0;
-
- return 0;
-}
-
-enum iconv_direction { iconv_from_native, iconv_to_native };
-
-static char *c_iconv(const char* str, enum iconv_direction dir)
-{
-#ifdef HAVE_ICONV_CONST
- const char *in = str;
-#else
- char *in = discard_const(str);
-#endif
- size_t size;
- size_t outsize;
- char *out;
- char *out_in;
- size_t ret;
-
- if (str == NULL) {
- return NULL;
- }
-
- if(_iconvs.from == NULL && _iconvs.to == NULL) {
-#ifdef __APPLE__
- c_setup_iconv("UTF-8-MAC");
-#else
- return c_strdup(str);
-#endif
- }
-
- size = strlen(in);
- outsize = size*2;
- out = c_malloc(outsize);
- out_in = out;
-
- if (dir == iconv_to_native) {
- ret = iconv(_iconvs.to, &in, &size, &out, &outsize);
- } else {
- ret = iconv(_iconvs.from, &in, &size, &out, &outsize);
- }
-
- if (ret == (size_t)-1) {
- SAFE_FREE(out_in);
- return NULL;
- }
-
- return out_in;
-}
-#endif /* defined(HAVE_ICONV) && defined(WITH_ICONV) */
-
int c_strncasecmp(const char *a, const char *b, size_t n) {
#ifdef _WIN32
return _strnicmp(a, b, n);
dst = mdst;
}
#else
-#ifdef WITH_ICONV
- dst = c_iconv(wstr, iconv_from_native);
-#else
- dst = (char*) wstr;
-#endif
+ dst = c_strdup(wstr);
#endif
return dst;
}
MultiByteToWideChar(CP_UTF8, 0, str, -1, dst, size_needed);
}
#else
-#ifdef WITH_ICONV
- dst = c_iconv(str, iconv_to_native);
-#else
- dst = (_TCHAR*) str;
-#endif
+ dst = c_strdup(str);
#endif
return dst;
}
*/
mbchar_t* c_utf8_string_to_locale(const char *wstr);
-#if defined(_WIN32) || defined(WITH_ICONV)
-
/**
* @brief Free buffer malloced by c_utf8_from_locale or c_utf8_to_locale().
*
*
*/
#define c_free_locale_string(x) SAFE_FREE(x)
-#else
-#define c_free_locale_string(x) (void)x
-#endif
+
/**
* }@