From 2afdc9d0958a48056757dd6124dd3c3aabcedcbc Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 18 Aug 2013 16:43:46 +0200 Subject: [PATCH] Adapt to new multybyte api after merge (Search and replace) --- src/csync_config.c | 2 +- src/csync_statedb.c | 10 +++++----- src/csync_util.c | 6 +++--- src/std/c_file.c | 26 +++++++++++++------------- src/std/c_time.c | 2 +- src/vio/csync_vio.c | 4 ++-- src/vio/csync_vio_local.c | 2 +- tests/ownCloud/mocka/ocmod_test.c | 8 ++++---- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/csync_config.c b/src/csync_config.c index f4811e4c3d..f6dd825bee 100644 --- a/src/csync_config.c +++ b/src/csync_config.c @@ -71,7 +71,7 @@ static int _csync_config_copy_default (const char *config) { int rc; #ifdef _WIN32 /* For win32, try to copy the conf file from the directory from where the app was started. */ - _TCHAR tcharbuf[MAX_PATH+1]; + mbchar_t tcharbuf[MAX_PATH+1]; char *buf; int len = 0; diff --git a/src/csync_statedb.c b/src/csync_statedb.c index d767e79a5b..f0a9acbfeb 100644 --- a/src/csync_statedb.c +++ b/src/csync_statedb.c @@ -62,12 +62,12 @@ int csync_get_statedb_exists(CSYNC *ctx) { /* Set the hide attribute in win32. That makes it invisible in normal explorers */ static void _csync_win32_hide_file( const char *file ) { #ifdef _WIN32 - _TCHAR *fileName; + mbchar_t *fileName; DWORD dwAttrs; if( !file ) return; - fileName = c_multibyte( file ); + fileName = c_utf8_to_locale( file ); dwAttrs = GetFileAttributesW(fileName); if (dwAttrs==INVALID_FILE_ATTRIBUTES) return; @@ -76,7 +76,7 @@ static void _csync_win32_hide_file( const char *file ) { SetFileAttributesW(fileName, dwAttrs | FILE_ATTRIBUTE_HIDDEN ); } - c_free_multibyte(fileName); + c_free_locale_string(fileName); #else (void) file; #endif @@ -398,10 +398,10 @@ int csync_statedb_close(const char *statedb, sqlite3 *db, int jwritten) { c_free_locale_string(mb_statedb); } - wstatedb_tmp = c_multibyte(statedb_tmp); + wstatedb_tmp = c_utf8_to_locale(statedb_tmp); if (wstatedb_tmp) { _tunlink(wstatedb_tmp); - c_free_multibyte(wstatedb_tmp); + c_free_locale_string(wstatedb_tmp); } SAFE_FREE(statedb_tmp); diff --git a/src/csync_util.c b/src/csync_util.c index c3462e5475..644d302b6d 100644 --- a/src/csync_util.c +++ b/src/csync_util.c @@ -375,11 +375,11 @@ out: void csync_win32_set_file_hidden( const char *file, bool h ) { #ifdef _WIN32 - const _TCHAR *fileName; + const mbchar_t *fileName; DWORD dwAttrs; if( !file ) return; - fileName = c_multibyte( file ); + fileName = c_utf8_to_locale( file ); dwAttrs = GetFileAttributesW(fileName); if (dwAttrs==INVALID_FILE_ATTRIBUTES) return; @@ -390,7 +390,7 @@ void csync_win32_set_file_hidden( const char *file, bool h ) { SetFileAttributesW(fileName, dwAttrs & ~FILE_ATTRIBUTE_HIDDEN ); } - c_free_multibyte(fileName); + c_free_locale_string(fileName); #else (void) h; (void) file; diff --git a/src/std/c_file.c b/src/std/c_file.c index 3b57d274c6..73decb8b51 100644 --- a/src/std/c_file.c +++ b/src/std/c_file.c @@ -64,17 +64,17 @@ int c_isfile(const char *path) { #ifdef _WIN32 int c_copy(const char* src, const char *dst, mode_t mode) { int rc = -1; - _TCHAR *wsrc = 0; - _TCHAR *wdst = 0; + mbchar_t *wsrc = 0; + mbchar_t *wdst = 0; (void) mode; /* unused on win32 */ if(src && dst) { - wsrc = c_multibyte(src); - wdst = c_multibyte(dst); + wsrc = c_utf8_to_locale(src); + wdst = c_utf8_to_locale(dst); if (CopyFileW(wsrc, wdst, FALSE)) { rc = 0; } - c_free_multibyte(wsrc); - c_free_multibyte(wdst); + c_free_locale_string(wsrc); + c_free_locale_string(wdst); if( rc < 0 ) { errno = GetLastError(); } @@ -193,8 +193,8 @@ out: } int c_rename( const char *src, const char *dst ) { - _TCHAR *nuri = NULL; - _TCHAR *ouri = NULL; + mbchar_t *nuri = NULL; + mbchar_t *ouri = NULL; int rc = 0; nuri = c_utf8_to_locale(dst); @@ -250,7 +250,7 @@ int c_rename( const char *src, const char *dst ) { } int c_compare_file( const char *f1, const char *f2 ) { - _TCHAR *wf1, *wf2; + mbchar_t *wf1, *wf2; int fd1 = -1, fd2 = -1; size_t size1, size2; char buffer1[BUFFER_SIZE]; @@ -262,11 +262,11 @@ int c_compare_file( const char *f1, const char *f2 ) { if(f1 == NULL || f2 == NULL) return -1; - wf1 = c_multibyte(f1); + wf1 = c_utf8_to_locale(f1); if(wf1 == NULL) { return -1; } - wf2 = c_multibyte(f2); + wf2 = c_utf8_to_locale(f2); if(wf2 == NULL) { return -1; } @@ -323,8 +323,8 @@ out: if(fd1 > -1) close(fd1); if(fd2 > -1) close(fd2); - c_free_multibyte(wf1); - c_free_multibyte(wf2); + c_free_locale_string(wf1); + c_free_locale_string(wf2); return rc; } diff --git a/src/std/c_time.c b/src/std/c_time.c index c6b89f5c0b..9f83c038c5 100644 --- a/src/std/c_time.c +++ b/src/std/c_time.c @@ -140,7 +140,7 @@ int c_utimes(const char *uri, const struct timeval *times) { } CloseHandle(hFile); - c_free_multibyte(wuri); + c_free_locale_string(wuri); return 0; } diff --git a/src/vio/csync_vio.c b/src/vio/csync_vio.c index e73cf45195..42f0a51380 100644 --- a/src/vio/csync_vio.c +++ b/src/vio/csync_vio.c @@ -99,11 +99,11 @@ int csync_vio_init(CSYNC *ctx, const char *module, const char *args) { /* cut the trailing filename off */ if ((last_bslash = strrchr(buf, '\\')) != NULL) { *last_bslash='\0'; - pathBuf = c_multibyte(buf); + pathBuf = c_utf8_to_locale(buf); CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Win32: changing current working dir to %s", buf); _wchdir(pathBuf); - c_free_multibyte(pathBuf); + c_free_locale_string(pathBuf); } c_free_utf8(buf); diff --git a/src/vio/csync_vio_local.c b/src/vio/csync_vio_local.c index 7eeae1e8f7..0a6cd32962 100644 --- a/src/vio/csync_vio_local.c +++ b/src/vio/csync_vio_local.c @@ -378,7 +378,7 @@ int csync_vio_local_stat(const char *uri, csync_vio_file_stat_t *buf) { FILE_ATTRIBUTE_NORMAL+FILE_FLAG_BACKUP_SEMANTICS, NULL ); if( h == INVALID_HANDLE_VALUE ) { errno = GetLastError(); - c_free_multibyte(wuri); + c_free_locale_string(wuri); return -1; } else { diff --git a/tests/ownCloud/mocka/ocmod_test.c b/tests/ownCloud/mocka/ocmod_test.c index 2af4a5fd1f..2b5a54c491 100644 --- a/tests/ownCloud/mocka/ocmod_test.c +++ b/tests/ownCloud/mocka/ocmod_test.c @@ -156,10 +156,10 @@ static void teardown_toplevel_dir( void **state ) { static void stat_local_file( csync_stat_t *sb, const char *file ) { - _TCHAR *mpath = NULL; - mpath = c_multibyte(file); + mbchar_t *mpath = NULL; + mpath = c_utf8_to_locale(file); assert_int_not_equal(_tstat(mpath, sb), -1); - c_free_multibyte(mpath); + c_free_locale_string(mpath); assert_null(mpath); } @@ -225,7 +225,7 @@ static void download_a_file( const char* local, void **state, const char *durl) char path[256]; char src_path[256]; int did; - _TCHAR tlocal[256]; + mbchar_t tlocal[256]; csync_vio_method_handle_t *handle; ssize_t count;