make calls to iconv functions depend on HAVE_ICONV
This commit is contained in:
parent
c01f625e79
commit
09fc39b814
20
src/webdav.c
20
src/webdav.c
@ -25,7 +25,9 @@
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#ifdef HAVE_ICONV_H
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
#ifdef HAVE_LANGINFO_H
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
@ -199,6 +201,7 @@ static int initialized;
|
||||
Needed by ssl_verify() which may be called at any time. */
|
||||
static int have_terminal;
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
/* Handle to convert character encoding from utf-8 to LC_CTYPE.
|
||||
If NULL no conversion is done. */
|
||||
static iconv_t from_utf_8;
|
||||
@ -214,6 +217,7 @@ static iconv_t from_server_enc;
|
||||
/* Handle to convert from LC_CTYPE to character encoding of path names.
|
||||
If NULL no conversion is done. */
|
||||
static iconv_t to_server_enc;
|
||||
#endif /* HAVE_ICONV */
|
||||
|
||||
/* A GNU custom stream, used to redirect neon debug messages to syslog. */
|
||||
static FILE *log_stream;
|
||||
@ -230,8 +234,10 @@ static char *cookie;
|
||||
/* Private function prototypes and inline functions */
|
||||
/*==================================================*/
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
static void
|
||||
convert(char **s, iconv_t conv);
|
||||
#endif
|
||||
|
||||
static int
|
||||
get_error(int ret, const char *method);
|
||||
@ -315,6 +321,7 @@ dav_init_webdav(const dav_args *args)
|
||||
if (args->neon_debug & ~NE_DBG_HTTPPLAIN)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "Initializing webdav");
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
char *lc_charset = nl_langinfo(CODESET);
|
||||
if (lc_charset && strcasecmp(lc_charset, "UTF-8") != 0) {
|
||||
from_utf_8 = iconv_open(lc_charset, "UTF-8");
|
||||
@ -339,6 +346,7 @@ dav_init_webdav(const dav_args *args)
|
||||
to_server_enc = 0;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_ICONV */
|
||||
|
||||
if (ne_sock_init() != 0)
|
||||
error(EXIT_FAILURE, errno, _("socket library initialization failed"));
|
||||
@ -541,8 +549,10 @@ char *
|
||||
dav_conv_from_utf_8(const char *s)
|
||||
{
|
||||
char *new = ne_strdup(s);
|
||||
#ifdef HAVE_ICONV
|
||||
if (from_utf_8)
|
||||
convert(&new, from_utf_8);
|
||||
#endif
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -551,8 +561,10 @@ char *
|
||||
dav_conv_to_utf_8(const char *s)
|
||||
{
|
||||
char *new = ne_strdup(s);
|
||||
#ifdef HAVE_ICONV
|
||||
if (to_utf_8)
|
||||
convert(&new, to_utf_8);
|
||||
#endif
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -561,8 +573,10 @@ char *
|
||||
dav_conv_from_server_enc(const char *s)
|
||||
{
|
||||
char *new = ne_strdup(s);
|
||||
#ifdef HAVE_ICONV
|
||||
if (from_server_enc)
|
||||
convert(&new, from_server_enc);
|
||||
#endif
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -571,8 +585,10 @@ char *
|
||||
dav_conv_to_server_enc(const char *s)
|
||||
{
|
||||
char *new = ne_strdup(s);
|
||||
#ifdef HAVE_ICONV
|
||||
if (to_server_enc)
|
||||
convert(&new, to_server_enc);
|
||||
#endif
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -1241,6 +1257,7 @@ dav_unlock(const char *path, time_t *expire)
|
||||
/* Private functions */
|
||||
/*===================*/
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
static void
|
||||
convert(char **s, iconv_t conv)
|
||||
{
|
||||
@ -1261,6 +1278,7 @@ convert(char **s, iconv_t conv)
|
||||
|
||||
free(buf);
|
||||
}
|
||||
#endif /* HAVE_ICONV */
|
||||
|
||||
|
||||
/* Returns a file error code according to ret from the last WebDAV
|
||||
@ -1775,8 +1793,10 @@ prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
|
||||
strlen(result->path) - strlen(ctx->path)
|
||||
- result->is_dir);
|
||||
replace_slashes(&result->name);
|
||||
#ifdef HAVE_ICONV
|
||||
if (from_server_enc)
|
||||
convert(&result->name, from_server_enc);
|
||||
#endif
|
||||
}
|
||||
|
||||
data = ne_propset_value(set, &prop_names[ETAG]);
|
||||
|
Loading…
Reference in New Issue
Block a user