aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Makefile.inc5
-rw-r--r--lib/base64.c32
-rw-r--r--lib/easy.c212
-rw-r--r--lib/easyif.h9
-rw-r--r--lib/escape.c27
-rw-r--r--lib/formdata.c39
-rw-r--r--lib/ftp.c8
-rw-r--r--lib/http.c36
-rw-r--r--lib/http_chunks.c18
-rw-r--r--lib/http_digest.c8
-rw-r--r--lib/http_ntlm.c34
-rw-r--r--lib/http_proxy.c3
-rw-r--r--lib/imap.c2
-rw-r--r--lib/non-ascii.c332
-rw-r--r--lib/non-ascii.h60
-rw-r--r--lib/nss.c1
-rw-r--r--lib/pingpong.c15
-rw-r--r--lib/pop3.c2
-rw-r--r--lib/rtsp.c1
-rw-r--r--lib/sendf.c10
-rw-r--r--lib/smtp.c2
-rw-r--r--lib/ssh.c2
-rw-r--r--lib/ssluse.c9
-rw-r--r--lib/transfer.c1
-rw-r--r--lib/url.c21
25 files changed, 469 insertions, 420 deletions
diff --git a/lib/Makefile.inc b/lib/Makefile.inc
index 65f2d7e2b..0e77b68d6 100644
--- a/lib/Makefile.inc
+++ b/lib/Makefile.inc
@@ -21,7 +21,8 @@ CSOURCES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
socks_gssapi.c socks_sspi.c curl_sspi.c slist.c nonblock.c \
curl_memrchr.c imap.c pop3.c smtp.c pingpong.c rtsp.c curl_threads.c \
warnless.c hmac.c polarssl.c curl_rtmp.c openldap.c curl_gethostname.c\
- gopher.c axtls.c idn_win32.c http_negotiate_sspi.c cyassl.c http_proxy.c
+ gopher.c axtls.c idn_win32.c http_negotiate_sspi.c cyassl.c http_proxy.c \
+ non-ascii.c
HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h \
progress.h formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h \
@@ -36,5 +37,5 @@ HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h \
curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h slist.h nonblock.h \
curl_memrchr.h imap.h pop3.h smtp.h pingpong.h rtsp.h curl_threads.h \
warnless.h curl_hmac.h polarssl.h curl_rtmp.h curl_gethostname.h \
- gopher.h axtls.h cyassl.h http_proxy.h
+ gopher.h axtls.h cyassl.h http_proxy.h non-ascii.h
diff --git a/lib/base64.c b/lib/base64.c
index 66ddb329c..0c492dc45 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -31,10 +31,10 @@
#include <curl/mprintf.h>
#include "urldata.h" /* for the SessionHandle definition */
-#include "easyif.h" /* for Curl_convert_... prototypes */
#include "warnless.h"
#include "curl_base64.h"
#include "curl_memory.h"
+#include "non-ascii.h"
/* include memdebug.h last */
#include "memdebug.h"
@@ -146,9 +146,7 @@ size_t Curl_base64_encode(struct SessionHandle *data,
int inputparts;
char *output;
char *base64data;
-#ifdef CURL_DOES_CONVERSIONS
char *convbuf = NULL;
-#endif
const char *indata = inputbuff;
@@ -161,29 +159,16 @@ size_t Curl_base64_encode(struct SessionHandle *data,
if(NULL == output)
return 0;
-#ifdef CURL_DOES_CONVERSIONS
/*
* The base64 data needs to be created using the network encoding
* not the host encoding. And we can't change the actual input
* so we copy it to a buffer, translate it, and use that instead.
*/
- if(data) {
- convbuf = malloc(insize);
- if(!convbuf) {
- free(output);
- return 0;
- }
- memcpy(convbuf, indata, insize);
- if(CURLE_OK != Curl_convert_to_network(data, convbuf, insize)) {
- free(convbuf);
- free(output);
- return 0;
- }
- indata = convbuf; /* switch to the converted buffer */
- }
-#else
- (void)data;
-#endif
+ if(Curl_convert_clone(data, indata, insize, &convbuf))
+ return 0;
+
+ if(convbuf)
+ indata = (char *)convbuf;
while(insize > 0) {
for (i = inputparts = 0; i < 3; i++) {
@@ -229,10 +214,9 @@ size_t Curl_base64_encode(struct SessionHandle *data,
*output=0;
*outptr = base64data; /* make it return the actual data memory */
-#ifdef CURL_DOES_CONVERSIONS
- if(data)
+ if(convbuf)
free(convbuf);
-#endif
+
return strlen(base64data); /* return the length of the new data */
}
/* ---- End of Base64 Encoding ---- */
diff --git a/lib/easy.c b/lib/easy.c
index 7015eced2..05d8ded9d 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -85,22 +85,11 @@
#include "connect.h" /* for Curl_getconnectinfo */
#include "slist.h"
#include "curl_rand.h"
+#include "non-ascii.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
-#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
-#include <iconv.h>
-/* set default codesets for iconv */
-#ifndef CURL_ICONV_CODESET_OF_NETWORK
-#define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1"
-#endif
-#ifndef CURL_ICONV_CODESET_FOR_UTF8
-#define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8"
-#endif
-#define ICONV_ERROR (size_t)-1
-#endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */
-
/* The last #include file should be: */
#include "memdebug.h"
@@ -694,14 +683,7 @@ CURL *curl_easy_duphandle(CURL *incurl)
goto fail;
#endif
-#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
- outcurl->inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
- CURL_ICONV_CODESET_OF_NETWORK);
- outcurl->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
- CURL_ICONV_CODESET_OF_HOST);
- outcurl->utf8_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
- CURL_ICONV_CODESET_FOR_UTF8);
-#endif
+ Curl_convert_setup(outcurl);
Curl_easy_initHandleData(outcurl);
@@ -863,196 +845,6 @@ CURLcode curl_easy_pause(CURL *curl, int action)
return result;
}
-#ifdef CURL_DOES_CONVERSIONS
-/*
- * Curl_convert_to_network() is an internal function
- * for performing ASCII conversions on non-ASCII platforms.
- */
-CURLcode Curl_convert_to_network(struct SessionHandle *data,
- char *buffer, size_t length)
-{
- CURLcode rc;
-
- if(data->set.convtonetwork) {
- /* use translation callback */
- rc = data->set.convtonetwork(buffer, length);
- if(rc != CURLE_OK) {
- failf(data,
- "CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %d: %s",
- (int)rc, curl_easy_strerror(rc));
- }
- return(rc);
- }
- else {
-#ifdef HAVE_ICONV
- /* do the translation ourselves */
- char *input_ptr, *output_ptr;
- size_t in_bytes, out_bytes, rc;
- int error;
-
- /* open an iconv conversion descriptor if necessary */
- if(data->outbound_cd == (iconv_t)-1) {
- data->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
- CURL_ICONV_CODESET_OF_HOST);
- if(data->outbound_cd == (iconv_t)-1) {
- error = ERRNO;
- failf(data,
- "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
- CURL_ICONV_CODESET_OF_NETWORK,
- CURL_ICONV_CODESET_OF_HOST,
- error, strerror(error));
- return CURLE_CONV_FAILED;
- }
- }
- /* call iconv */
- input_ptr = output_ptr = buffer;
- in_bytes = out_bytes = length;
- rc = iconv(data->outbound_cd, (const char**)&input_ptr, &in_bytes,
- &output_ptr, &out_bytes);
- if((rc == ICONV_ERROR) || (in_bytes != 0)) {
- error = ERRNO;
- failf(data,
- "The Curl_convert_to_network iconv call failed with errno %i: %s",
- error, strerror(error));
- return CURLE_CONV_FAILED;
- }
-#else
- failf(data, "CURLOPT_CONV_TO_NETWORK_FUNCTION callback required");
- return CURLE_CONV_REQD;
-#endif /* HAVE_ICONV */
- }
-
- return CURLE_OK;
-}
-
-/*
- * Curl_convert_from_network() is an internal function
- * for performing ASCII conversions on non-ASCII platforms.
- */
-CURLcode Curl_convert_from_network(struct SessionHandle *data,
- char *buffer, size_t length)
-{
- CURLcode rc;
-
- if(data->set.convfromnetwork) {
- /* use translation callback */
- rc = data->set.convfromnetwork(buffer, length);
- if(rc != CURLE_OK) {
- failf(data,
- "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %d: %s",
- (int)rc, curl_easy_strerror(rc));
- }
- return(rc);
- }
- else {
-#ifdef HAVE_ICONV
- /* do the translation ourselves */
- char *input_ptr, *output_ptr;
- size_t in_bytes, out_bytes, rc;
- int error;
-
- /* open an iconv conversion descriptor if necessary */
- if(data->inbound_cd == (iconv_t)-1) {
- data->inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
- CURL_ICONV_CODESET_OF_NETWORK);
- if(data->inbound_cd == (iconv_t)-1) {
- error = ERRNO;
- failf(data,
- "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
- CURL_ICONV_CODESET_OF_HOST,
- CURL_ICONV_CODESET_OF_NETWORK,
- error, strerror(error));
- return CURLE_CONV_FAILED;
- }
- }
- /* call iconv */
- input_ptr = output_ptr = buffer;
- in_bytes = out_bytes = length;
- rc = iconv(data->inbound_cd, (const char **)&input_ptr, &in_bytes,
- &output_ptr, &out_bytes);
- if((rc == ICONV_ERROR) || (in_bytes != 0)) {
- error = ERRNO;
- failf(data,
- "The Curl_convert_from_network iconv call failed with errno %i: %s",
- error, strerror(error));
- return CURLE_CONV_FAILED;
- }
-#else
- failf(data, "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback required");
- return CURLE_CONV_REQD;
-#endif /* HAVE_ICONV */
- }
-
- return CURLE_OK;
-}
-
-/*
- * Curl_convert_from_utf8() is an internal function
- * for performing UTF-8 conversions on non-ASCII platforms.
- */
-CURLcode Curl_convert_from_utf8(struct SessionHandle *data,
- char *buffer, size_t length)
-{
- CURLcode rc;
-
- if(data->set.convfromutf8) {
- /* use translation callback */
- rc = data->set.convfromutf8(buffer, length);
- if(rc != CURLE_OK) {
- failf(data,
- "CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %d: %s",
- (int)rc, curl_easy_strerror(rc));
- }
- return(rc);
- }
- else {
-#ifdef HAVE_ICONV
- /* do the translation ourselves */
- const char *input_ptr;
- char *output_ptr;
- size_t in_bytes, out_bytes, rc;
- int error;
-
- /* open an iconv conversion descriptor if necessary */
- if(data->utf8_cd == (iconv_t)-1) {
- data->utf8_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
- CURL_ICONV_CODESET_FOR_UTF8);
- if(data->utf8_cd == (iconv_t)-1) {
- error = ERRNO;
- failf(data,
- "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
- CURL_ICONV_CODESET_OF_HOST,
- CURL_ICONV_CODESET_FOR_UTF8,
- error, strerror(error));
- return CURLE_CONV_FAILED;
- }
- }
- /* call iconv */
- input_ptr = output_ptr = buffer;
- in_bytes = out_bytes = length;
- rc = iconv(data->utf8_cd, &input_ptr, &in_bytes,
- &output_ptr, &out_bytes);
- if((rc == ICONV_ERROR) || (in_bytes != 0)) {
- error = ERRNO;
- failf(data,
- "The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
- error, strerror(error));
- return CURLE_CONV_FAILED;
- }
- if(output_ptr < input_ptr) {
- /* null terminate the now shorter output string */
- *output_ptr = 0x00;
- }
-#else
- failf(data, "CURLOPT_CONV_FROM_UTF8_FUNCTION callback required");
- return CURLE_CONV_REQD;
-#endif /* HAVE_ICONV */
- }
-
- return CURLE_OK;
-}
-
-#endif /* CURL_DOES_CONVERSIONS */
static CURLcode easy_connection(struct SessionHandle *data,
curl_socket_t *sfd,
diff --git a/lib/easyif.h b/lib/easyif.h
index 8a0a51cc1..d05b7d610 100644
--- a/lib/easyif.h
+++ b/lib/easyif.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -29,11 +29,4 @@ void Curl_easy_addmulti(struct SessionHandle *data, void *multi);
void Curl_easy_initHandleData(struct SessionHandle *data);
-CURLcode Curl_convert_to_network(struct SessionHandle *data,
- char *buffer, size_t length);
-CURLcode Curl_convert_from_network(struct SessionHandle *data,
- char *buffer, size_t length);
-CURLcode Curl_convert_from_utf8(struct SessionHandle *data,
- char *buffer, size_t length);
-
#endif /* __EASYIF_H */
diff --git a/lib/escape.c b/lib/escape.c
index 735e1d8a7..4e8dd6e4c 100644
--- a/lib/escape.c
+++ b/lib/escape.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -31,10 +31,9 @@
#include <stdlib.h>
#include <string.h>
#include "curl_memory.h"
-/* urldata.h and easyif.h are included for Curl_convert_... prototypes */
#include "urldata.h"
-#include "easyif.h"
#include "warnless.h"
+#include "non-ascii.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -91,10 +90,6 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
int strindex=0;
size_t length;
-#ifndef CURL_DOES_CONVERSIONS
- /* avoid compiler warnings */
- (void)handle;
-#endif
ns = malloc(alloc);
if(!ns)
return NULL;
@@ -122,15 +117,11 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
}
}
-#ifdef CURL_DOES_CONVERSIONS
-/* escape sequences are always in ASCII so convert them on non-ASCII hosts */
- if(!handle ||
- (Curl_convert_to_network(handle, &in, 1) != CURLE_OK)) {
+ if(Curl_convert_to_network(handle, &in, 1)) {
/* Curl_convert_to_network calls failf if unsuccessful */
free(ns);
return NULL;
}
-#endif /* CURL_DOES_CONVERSIONS */
snprintf(&ns[strindex], 4, "%%%02X", in);
@@ -157,11 +148,7 @@ char *curl_easy_unescape(CURL *handle, const char *string, int length,
int strindex=0;
unsigned long hex;
-#ifndef CURL_DOES_CONVERSIONS
- /* avoid compiler warnings */
- (void)handle;
-#endif
- if( !ns )
+ if(!ns)
return NULL;
while(--alloc > 0) {
@@ -178,15 +165,11 @@ char *curl_easy_unescape(CURL *handle, const char *string, int length,
in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */
-#ifdef CURL_DOES_CONVERSIONS
-/* escape sequences are always in ASCII so convert them on non-ASCII hosts */
- if(!handle ||
- (Curl_convert_from_network(handle, &in, 1) != CURLE_OK)) {
+ if(Curl_convert_from_network(handle, &in, 1)) {
/* Curl_convert_from_network calls failf if unsuccessful */
free(ns);
return NULL;
}
-#endif /* CURL_DOES_CONVERSIONS */
string+=2;
alloc-=2;
diff --git a/lib/formdata.c b/lib/formdata.c
index 5ec3e384e..f221ae966 100644
--- a/lib/formdata.c
+++ b/lib/formdata.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -118,7 +118,6 @@ Content-Disposition: form-data; name="FILECONTENT"
#include <libgen.h>
#endif
#include "urldata.h" /* for struct SessionHandle */
-#include "easyif.h" /* for Curl_convert_... prototypes */
#include "formdata.h"
#include "curl_rand.h"
#include "strequal.h"
@@ -461,8 +460,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
*/
case CURLFORM_PTRNAME:
#ifdef CURL_DOES_CONVERSIONS
- /* treat CURLFORM_PTR like CURLFORM_COPYNAME so we'll
- have safe memory for the eventual conversion */
+ /* Treat CURLFORM_PTR like CURLFORM_COPYNAME so that libcurl will copy
+ * the data in all cases so that we'll have safe memory for the eventual
+ * conversion.
+ */
#else
current_form->flags |= HTTPPOST_PTRNAME; /* fall through */
#endif
@@ -934,36 +935,6 @@ void Curl_formclean(struct FormData **form_ptr)
*form_ptr = NULL;
}
-#ifdef CURL_DOES_CONVERSIONS
-/*
- * Curl_formcovert() is used from http.c, this converts any
- form items that need to be sent in the network encoding.
- Returns CURLE_OK on success.
- */
-CURLcode Curl_formconvert(struct SessionHandle *data, struct FormData *form)
-{
- struct FormData *next;
- CURLcode rc;
-
- if(!form)
- return CURLE_OK;
-
- if(!data)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- do {
- next=form->next; /* the following form line */
- if(form->type == FORM_DATA) {
- rc = Curl_convert_to_network(data, form->line, form->length);
- /* Curl_convert_to_network calls failf if unsuccessful */
- if(rc != CURLE_OK)
- return rc;
- }
- } while((form = next) != NULL); /* continue */
- return CURLE_OK;
-}
-#endif /* CURL_DOES_CONVERSIONS */
-
/*
* curl_formget()
* Serialize a curl_httppost struct.
diff --git a/lib/ftp.c b/lib/ftp.c
index 154a03607..d08ae3fff 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -61,8 +61,6 @@
#include <curl/curl.h>
#include "urldata.h"
#include "sendf.h"
-#include "easyif.h" /* for Curl_convert_... prototypes */
-
#include "if2ip.h"
#include "hostip.h"
#include "progress.h"
@@ -94,6 +92,7 @@
#include "speedcheck.h"
#include "warnless.h"
#include "http_proxy.h"
+#include "non-ascii.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -3772,13 +3771,10 @@ CURLcode Curl_ftpsendf(struct connectdata *conn,
bytes_written=0;
write_len = strlen(s);
-#ifdef CURL_DOES_CONVERSIONS
res = Curl_convert_to_network(conn->data, s, write_len);
/* Curl_convert_to_network calls failf if unsuccessful */
- if(res != CURLE_OK) {
+ if(res)
return(res);
- }
-#endif /* CURL_DOES_CONVERSIONS */
for(;;) {
#if defined(HAVE_KRB4) || defined(HAVE_GSSAPI)
diff --git a/lib/http.c b/lib/http.c
index 4f2b46a59..960bb4279 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -76,7 +76,6 @@
#include <curl/curl.h>
#include "transfer.h"
#include "sendf.h"
-#include "easyif.h" /* for Curl_convert_... prototypes */
#include "formdata.h"
#include "progress.h"
#include "curl_base64.h"
@@ -100,6 +99,7 @@
#include "rtsp.h"
#include "http_proxy.h"
#include "warnless.h"
+#include "non-ascii.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -1014,17 +1014,15 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
DEBUGASSERT(size > included_body_bytes);
-#ifdef CURL_DOES_CONVERSIONS
res = Curl_convert_to_network(conn->data, ptr, headersize);
/* Curl_convert_to_network calls failf if unsuccessful */
- if(res != CURLE_OK) {
+ if(res) {
/* conversion failed, free memory and return to the caller */
if(in->buffer)
free(in->buffer);
free(in);
return res;
}
-#endif /* CURL_DOES_CONVERSIONS */
if(conn->handler->protocol & CURLPROTO_HTTPS) {
/* We never send more than CURL_MAX_WRITE_SIZE bytes in one single chunk
@@ -2292,14 +2290,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
Curl_formclean(&http->sendit); /* free that whole lot */
return result;
}
-#ifdef CURL_DOES_CONVERSIONS
-/* time to convert the form data... */
- result = Curl_formconvert(data, http->sendit);
+
+ /* convert the form data */
+ result = Curl_convert_form(data, http->sendit);
if(result) {
Curl_formclean(&http->sendit); /* free that whole lot */
return result;
}
-#endif /* CURL_DOES_CONVERSIONS */
+
break;
case HTTPREQ_PUT: /* Let's PUT the data to the server! */
@@ -2538,13 +2536,13 @@ checkhttpprefix(struct SessionHandle *data,
/* convert from the network encoding using a scratch area */
char *scratch = strdup(s);
if(NULL == scratch) {
- failf (data, "Failed to allocate memory for conversion!");
- return FALSE; /* can't return CURLE_OUT_OF_MEMORY so return FALSE */
+ failf (data, "Failed to allocate memory for conversion!");
+ return FALSE; /* can't return CURLE_OUT_OF_MEMORY so return FALSE */
}
if(CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s)+1)) {
/* Curl_convert_from_network calls failf if unsuccessful */
- free(scratch);
- return FALSE; /* can't return CURLE_foobar so return FALSE */
+ free(scratch);
+ return FALSE; /* can't return CURLE_foobar so return FALSE */
}
s = scratch;
#endif /* CURL_DOES_CONVERSIONS */
@@ -2557,9 +2555,8 @@ checkhttpprefix(struct SessionHandle *data,
head = head->next;
}
- if((rc != TRUE) && (checkprefix("HTTP/", s))) {
+ if((rc != TRUE) && (checkprefix("HTTP/", s)))
rc = TRUE;
- }
#ifdef CURL_DOES_CONVERSIONS
free(scratch);
@@ -2931,10 +2928,9 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
res = Curl_convert_from_network(data,
&scratch[0],
SCRATCHSIZE);
- if(CURLE_OK != res) {
+ if(res)
/* Curl_convert_from_network calls failf if unsuccessful */
return res;
- }
#else
#define HEADER1 k->p /* no conversion needed, just use k->p */
#endif /* CURL_DOES_CONVERSIONS */
@@ -3065,14 +3061,10 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
}
}
-#ifdef CURL_DOES_CONVERSIONS
- /* convert from the network encoding */
result = Curl_convert_from_network(data, k->p, strlen(k->p));
- if(CURLE_OK != result) {
- return(result);
- }
/* Curl_convert_from_network calls failf if unsuccessful */
-#endif /* CURL_DOES_CONVERSIONS */
+ if(result)
+ return result;
/* Check for Content-Length: header lines to get size */
if(!k->ignorecl && !data->set.ignorecl &&
diff --git a/lib/http_chunks.c b/lib/http_chunks.c
index e955b945e..821a861f4 100644
--- a/lib/http_chunks.c
+++ b/lib/http_chunks.c
@@ -35,7 +35,7 @@
#include "content_encoding.h"
#include "http.h"
#include "curl_memory.h"
-#include "easyif.h" /* for Curl_convert_to_network prototype */
+#include "non-ascii.h" /* for Curl_convert_to_network prototype */
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -153,17 +153,16 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
}
/* length and datap are unmodified */
ch->hexbuffer[ch->hexindex]=0;
-#ifdef CURL_DOES_CONVERSIONS
+
/* convert to host encoding before calling strtoul */
- result = Curl_convert_from_network(conn->data,
- ch->hexbuffer,
+ result = Curl_convert_from_network(conn->data, ch->hexbuffer,
ch->hexindex);
- if(result != CURLE_OK) {
+ if(result) {
/* Curl_convert_from_network calls failf if unsuccessful */
/* Treat it as a bad hex character */
return(CHUNKE_ILLEGAL_HEX);
}
-#endif /* CURL_DOES_CONVERSIONS */
+
ch->datasize=strtoul(ch->hexbuffer, NULL, 16);
ch->state = CHUNK_POSTHEX;
}
@@ -297,17 +296,14 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
conn->trailer[conn->trlPos++]=0x0a;
conn->trailer[conn->trlPos]=0;
-#ifdef CURL_DOES_CONVERSIONS
/* Convert to host encoding before calling Curl_client_write */
- result = Curl_convert_from_network(conn->data,
- conn->trailer,
+ result = Curl_convert_from_network(conn->data, conn->trailer,
conn->trlPos);
- if(result != CURLE_OK)
+ if(result)
/* Curl_convert_from_network calls failf if unsuccessful */
/* Treat it as a bad chunk */
return CHUNKE_BAD_CHUNK;
-#endif /* CURL_DOES_CONVERSIONS */
if(!data->set.http_te_skip) {
result = Curl_client_write(conn, CLIENTWRITE_HEADER,
conn->trailer, conn->trlPos);
diff --git a/lib/http_digest.c b/lib/http_digest.c
index 45d8aeba8..4993a987d 100644
--- a/lib/http_digest.c
+++ b/lib/http_digest.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -38,7 +38,7 @@
#include "strtok.h"
#include "url.h" /* for Curl_safefree() */
#include "curl_memory.h"
-#include "easyif.h" /* included for Curl_convert_... prototypes */
+#include "non-ascii.h" /* included for Curl_convert_... prototypes */
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -294,7 +294,6 @@ CURLcode Curl_output_digest(struct connectdata *conn,
struct SessionHandle *data = conn->data;
struct digestdata *d;
-#ifdef CURL_DOES_CONVERSIONS
CURLcode rc;
/* The CURL_OUTPUT_DIGEST_CONV macro below is for non-ASCII machines.
It converts digest text to ASCII so the MD5 will be correct for
@@ -306,9 +305,6 @@ CURLcode Curl_output_digest(struct connectdata *conn,
free(b); \
return rc; \
}
-#else
-#define CURL_OUTPUT_DIGEST_CONV(a, b)
-#endif /* CURL_DOES_CONVERSIONS */
if(proxy) {
d = &data->state.proxydigest;
diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c
index f5b696a69..d1f2edd45 100644
--- a/lib/http_ntlm.c
+++ b/lib/http_ntlm.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -52,7 +52,7 @@
#endif
#include "urldata.h"
-#include "easyif.h" /* for Curl_convert_... prototypes */
+#include "non-ascii.h" /* for Curl_convert_... prototypes */
#include "sendf.h"
#include "rawstr.h"
#include "curl_base64.h"
@@ -525,16 +525,12 @@ static void mk_lm_hash(struct SessionHandle *data,
Curl_strntoupper((char *)pw, password, len);
memset(&pw[len], 0, 14-len);
-#ifdef CURL_DOES_CONVERSIONS
/*
* The LanManager hashed password needs to be created using the
* password in the network encoding not the host encoding.
*/
- if(data)
- Curl_convert_to_network(data, (char *)pw, 14);
-#else
- (void)data;
-#endif
+ if(Curl_convert_to_network(data, (char *)pw, 14))
+ return;
{
/* Create LanManager hashed password. */
@@ -590,21 +586,19 @@ static CURLcode mk_nt_hash(struct SessionHandle *data,
{
size_t len = strlen(password);
unsigned char *pw = malloc(len*2);
+ CURLcode result;
if(!pw)
return CURLE_OUT_OF_MEMORY;
ascii_to_unicode_le(pw, password, len);
-#ifdef CURL_DOES_CONVERSIONS
/*
- * The NT hashed password needs to be created using the
- * password in the network encoding not the host encoding.
+ * The NT hashed password needs to be created using the password in the
+ * network encoding not the host encoding.
*/
- if(data)
- Curl_convert_to_network(data, (char *)pw, len*2);
-#else
- (void)data;
-#endif
+ result = Curl_convert_to_network(data, (char *)pw, len*2);
+ if(result)
+ return result;
{
/* Create NT hashed password. */
@@ -1244,14 +1238,10 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
memcpy(&ntlmbuf[size], host, hostlen);
size += hostlen;
-#ifdef CURL_DOES_CONVERSIONS
/* convert domain, user, and host to ASCII but leave the rest as-is */
- if(CURLE_OK != Curl_convert_to_network(conn->data,
- (char *)&ntlmbuf[domoff],
- size-domoff)) {
+ if(Curl_convert_to_network(conn->data, (char *)&ntlmbuf[domoff],
+ size-domoff))
return CURLE_CONV_FAILED;
- }
-#endif /* CURL_DOES_CONVERSIONS */
#endif
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
index 7631ae53c..99f3f0a70 100644
--- a/lib/http_proxy.c
+++ b/lib/http_proxy.c
@@ -33,6 +33,7 @@
#include "select.h"
#include "rawstr.h"
#include "progress.h"
+#include "non-ascii.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -315,14 +316,12 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
char letter;
int writetype;
-#ifdef CURL_DOES_CONVERSIONS
/* convert from the network encoding */
result = Curl_convert_from_network(data, line_start,
perline);
/* Curl_convert_from_network calls failf if unsuccessful */
if(result)
return result;
-#endif /* CURL_DOES_CONVERSIONS */
/* output debug if that is requested */
if(data->set.verbose)
diff --git a/lib/imap.c b/lib/imap.c
index 8f6efc427..b6f807a4b 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -64,8 +64,6 @@
#include <curl/curl.h>
#include "urldata.h"
#include "sendf.h"
-#include "easyif.h" /* for Curl_convert_... prototypes */
-
#include "if2ip.h"
#include "hostip.h"
#include "progress.h"
diff --git a/lib/non-ascii.c b/lib/non-ascii.c
new file mode 100644
index 000000000..945178e53
--- /dev/null
+++ b/lib/non-ascii.c
@@ -0,0 +1,332 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "setup.h"
+
+#ifdef CURL_DOES_CONVERSIONS
+
+#ifdef HAVE_ICONV
+#include <iconv.h>
+/* set default codesets for iconv */
+#ifndef CURL_ICONV_CODESET_OF_NETWORK
+#define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1"
+#endif
+#ifndef CURL_ICONV_CODESET_FOR_UTF8
+#define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8"
+#endif
+#define ICONV_ERROR (size_t)-1
+#endif /* HAVE_ICONV */
+
+/*
+ * Curl_convertclone() returns a malloced copy of the source string (if
+ * returning CURLE_OK), with the data converted to network format.
+ */
+CURLcode Curl_convertclone(struct SessionHandle *data,
+ const char *indata,
+ size_t insize,
+ char **outbuf)
+{
+ char *convbuf;
+ CURLcode result;
+
+ convbuf = malloc(insize);
+ if(!convbuf)
+ return CURLE_OUT_OF_MEMORY;
+
+ memcpy(convbuf, indata, insize);
+ result = Curl_convert_to_network(data, convbuf, insize);
+ if(result) {s
+ free(convbuf);
+ return result;
+ }
+
+ *outbuf = convbuf; /* return the converted buffer */
+
+ return CURLE_OK;
+}
+
+/*
+ * Curl_convert_to_network() is an internal function for performing ASCII
+ * conversions on non-ASCII platforms. It convers the buffer _in place_.
+ */
+CURLcode Curl_convert_to_network(struct SessionHandle *data,
+ char *buffer, size_t length)
+{
+ CURLcode rc;
+
+ if(data->set.convtonetwork) {
+ /* use translation callback */
+ rc = data->set.convtonetwork(buffer, length);
+ if(rc != CURLE_OK) {
+ failf(data,
+ "CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %d: %s",
+ (int)rc, curl_easy_strerror(rc));
+ }
+ return rc;
+ }
+ else {
+#ifdef HAVE_ICONV
+ /* do the translation ourselves */
+ char *input_ptr, *output_ptr;
+ size_t in_bytes, out_bytes, rc;
+ int error;
+
+ /* open an iconv conversion descriptor if necessary */
+ if(data->outbound_cd == (iconv_t)-1) {
+ data->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
+ CURL_ICONV_CODESET_OF_HOST);
+ if(data->outbound_cd == (iconv_t)-1) {
+ error = ERRNO;
+ failf(data,
+ "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
+ CURL_ICONV_CODESET_OF_NETWORK,
+ CURL_ICONV_CODESET_OF_HOST,
+ error, strerror(error));
+ return CURLE_CONV_FAILED;
+ }
+ }
+ /* call iconv */
+ input_ptr = output_ptr = buffer;
+ in_bytes = out_bytes = length;
+ rc = iconv(data->outbound_cd, (const char**)&input_ptr, &in_bytes,
+ &output_ptr, &out_bytes);
+ if((rc == ICONV_ERROR) || (in_bytes != 0)) {
+ error = ERRNO;
+ failf(data,
+ "The Curl_convert_to_network iconv call failed with errno %i: %s",
+ error, strerror(error));
+ return CURLE_CONV_FAILED;
+ }
+#else
+ failf(data, "CURLOPT_CONV_TO_NETWORK_FUNCTION callback required");
+ return CURLE_CONV_REQD;
+#endif /* HAVE_ICONV */
+ }
+
+ return CURLE_OK;
+}
+
+/*
+ * Curl_convert_from_network() is an internal function for performing ASCII
+ * conversions on non-ASCII platforms. It convers the buffer _in place_.
+ */
+CURLcode Curl_convert_from_network(struct SessionHandle *data,
+ char *buffer, size_t length)
+{
+ CURLcode rc;
+
+ if(data->set.convfromnetwork) {
+ /* use translation callback */
+ rc = data->set.convfromnetwork(buffer, length);
+ if(rc != CURLE_OK) {
+ failf(data,
+ "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %d: %s",
+ (int)rc, curl_easy_strerror(rc));
+ }
+ return rc;
+ }
+ else {
+#ifdef HAVE_ICONV
+ /* do the translation ourselves */
+ char *input_ptr, *output_ptr;
+ size_t in_bytes, out_bytes, rc;
+ int error;
+
+ /* open an iconv conversion descriptor if necessary */
+ if(data->inbound_cd == (iconv_t)-1) {
+ data->inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
+ CURL_ICONV_CODESET_OF_NETWORK);
+ if(data->inbound_cd == (iconv_t)-1) {
+ error = ERRNO;
+ failf(data,
+ "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
+ CURL_ICONV_CODESET_OF_HOST,
+ CURL_ICONV_CODESET_OF_NETWORK,
+ error, strerror(error));
+ return CURLE_CONV_FAILED;
+ }
+ }
+ /* call iconv */
+ input_ptr = output_ptr = buffer;
+ in_bytes = out_bytes = length;
+ rc = iconv(data->inbound_cd, (const char **)&input_ptr, &in_bytes,
+ &output_ptr, &out_bytes);
+ if((rc == ICONV_ERROR) || (in_bytes != 0)) {
+ error = ERRNO;
+ failf(data,
+ "The Curl_convert_from_network iconv call failed with errno %i: %s",
+ error, strerror(error));
+ return CURLE_CONV_FAILED;
+ }
+#else
+ failf(data, "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback required");
+ return CURLE_CONV_REQD;
+#endif /* HAVE_ICONV */
+ }
+
+ return CURLE_OK;
+}
+
+/*
+ * Curl_convert_from_utf8() is an internal function for performing UTF-8
+ * conversions on non-ASCII platforms.
+ */
+CURLcode Curl_convert_from_utf8(struct SessionHandle *data,
+ char *buffer, size_t length)
+{
+ CURLcode rc;
+
+ if(data->set.convfromutf8) {
+ /* use translation callback */
+ rc = data->set.convfromutf8(buffer, length);
+ if(rc != CURLE_OK) {
+ failf(data,
+ "CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %d: %s",
+ (int)rc, curl_easy_strerror(rc));
+ }
+ return rc;
+ }
+ else {
+#ifdef HAVE_ICONV
+ /* do the translation ourselves */
+ const char *input_ptr;
+ char *output_ptr;
+ size_t in_bytes, out_bytes, rc;
+ int error;
+
+ /* open an iconv conversion descriptor if necessary */
+ if(data->utf8_cd == (iconv_t)-1) {
+ data->utf8_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
+ CURL_ICONV_CODESET_FOR_UTF8);
+ if(data->utf8_cd == (iconv_t)-1) {
+ error = ERRNO;
+ failf(data,
+ "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
+ CURL_ICONV_CODESET_OF_HOST,
+ CURL_ICONV_CODESET_FOR_UTF8,
+ error, strerror(error));
+ return CURLE_CONV_FAILED;
+ }
+ }
+ /* call iconv */
+ input_ptr = output_ptr = buffer;
+ in_bytes = out_bytes = length;
+ rc = iconv(data->utf8_cd, &input_ptr, &in_bytes,
+ &output_ptr, &out_bytes);
+ if((rc == ICONV_ERROR) || (in_bytes != 0)) {
+ error = ERRNO;
+ failf(data,
+ "The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
+ error, strerror(error));
+ return CURLE_CONV_FAILED;
+ }
+ if(output_ptr < input_ptr) {
+ /* null terminate the now shorter output string */
+ *output_ptr = 0x00;
+ }
+#else
+ failf(data, "CURLOPT_CONV_FROM_UTF8_FUNCTION callback required");
+ return CURLE_CONV_REQD;
+#endif /* HAVE_ICONV */
+ }
+
+ return CURLE_OK;
+}
+
+/*
+ * Init conversion stuff for a SessionHandle
+ */
+void Curl_convert_init(struct SessionHandle *data)
+{
+#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
+ /* conversion descriptors for iconv calls */
+ data->outbound_cd = (iconv_t)-1;
+ data->inbound_cd = (iconv_t)-1;
+ data->utf8_cd = (iconv_t)-1;
+#else
+ (void)data;
+#endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */
+}
+
+/*
+ * Setup conversion stuff for a SessionHandle
+ */
+void Curl_convert_setup(struct SessionHandle *data)
+{
+ data->inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
+ CURL_ICONV_CODESET_OF_NETWORK);
+ data->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
+ CURL_ICONV_CODESET_OF_HOST);
+ data->utf8_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
+ CURL_ICONV_CODESET_FOR_UTF8);
+}
+
+/*
+ * Close conversion stuff for a SessionHandle
+ */
+
+void Curl_convert_close(struct SessionHandle *data)
+{
+#ifdef HAVE_ICONV
+ /* close iconv conversion descriptors */
+ if(data->inbound_cd != (iconv_t)-1) {
+ iconv_close(data->inbound_cd);
+ }
+ if(data->outbound_cd != (iconv_t)-1) {
+ iconv_close(data->outbound_cd);
+ }
+ if(data->utf8_cd != (iconv_t)-1) {
+ iconv_close(data->utf8_cd);
+ }
+#else
+ (void)data;
+#endif /* HAVE_ICONV */
+}
+
+/*
+ * Curl_convert_form() is used from http.c, this converts any form items that
+ need to be sent in the network encoding. Returns CURLE_OK on success.
+ */
+CURLcode Curl_convert_form(struct SessionHandle *data, struct FormData *form)
+{
+ struct FormData *next;
+ CURLcode rc;
+
+ if(!form)
+ return CURLE_OK;
+
+ if(!data)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ do {
+ next=form->next; /* the following form line */
+ if(form->type == FORM_DATA) {
+ rc = Curl_convert_to_network(data, form->line, form->length);
+ /* Curl_convert_to_network calls failf if unsuccessful */
+ if(rc != CURLE_OK)
+ return rc;
+ }
+ } while((form = next) != NULL); /* continue */
+ return CURLE_OK;
+}
+
+#endif /* CURL_DOES_CONVERSIONS */
diff --git a/lib/non-ascii.h b/lib/non-ascii.h
new file mode 100644
index 000000000..cccb11f25
--- /dev/null
+++ b/lib/non-ascii.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "setup.h"
+
+#ifdef CURL_DOES_CONVERSIONS
+
+#include "urldata.h"
+
+/*
+ * Curl_convertclone() returns a malloced copy of the source string (if
+ * returning CURLE_OK), with the data converted to network format.
+ *
+ * If no conversion was needed *outbuf may be NULL.
+ */
+CURLcode Curl_convert_clone(struct SessionHandle *data,
+ const char *indata,
+ size_t insize,
+ char **outbuf);
+
+void Curl_convert_init(struct SessionHandle *data);
+void Curl_convert_setup(struct SessionHandle *data);
+void Curl_convert_close(struct SessionHandle *data);
+
+CURLcode Curl_convert_to_network(struct SessionHandle *data,
+ char *buffer, size_t length);
+CURLcode Curl_convert_from_network(struct SessionHandle *data,
+ char *buffer, size_t length);
+CURLcode Curl_convert_from_utf8(struct SessionHandle *data,
+ char *buffer, size_t length);
+CURLcode Curl_convert_form(struct SessionHandle *data, struct FormData *form);
+#else
+#define Curl_convert_clone(a,b,c,d) \
+ ((void)a, (void)b, (void)c, *(d)=NULL, CURLE_OK)
+#define Curl_convert_init(x)
+#define Curl_convert_setup(x)
+#define Curl_convert_close(x)
+#define Curl_convert_to_network(a,b,c) ((void)a, CURLE_OK)
+#define Curl_convert_from_network(a,b,c) ((void)a, CURLE_OK)
+#define Curl_convert_from_utf8(a,b,c) ((void)a, CURLE_OK)
+#define Curl_convert_form(a,b) CURLE_OK
+#endif
diff --git a/lib/nss.c b/lib/nss.c
index d93937755..3677043f0 100644
--- a/lib/nss.c
+++ b/lib/nss.c
@@ -68,7 +68,6 @@
#include "curl_memory.h"
#include "rawstr.h"
-#include "easyif.h" /* for Curl_convert_from_utf8 prototype */
/* The last #include file should be: */
#include "memdebug.h"
diff --git a/lib/pingpong.c b/lib/pingpong.c
index 67ce63e59..a49aad960 100644
--- a/lib/pingpong.c
+++ b/lib/pingpong.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -32,6 +32,7 @@
#include "speedcheck.h"
#include "pingpong.h"
#include "multiif.h"
+#include "non-ascii.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -208,13 +209,10 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
Curl_pp_init(pp);
-#ifdef CURL_DOES_CONVERSIONS
res = Curl_convert_to_network(data, s, write_len);
/* Curl_convert_to_network calls failf if unsuccessful */
- if(res != CURLE_OK) {
+ if(res)
return res;
- }
-#endif /* CURL_DOES_CONVERSIONS */
#if defined(HAVE_KRB4) || defined(HAVE_GSSAPI)
conn->data_prot = PROT_CMD;
@@ -344,13 +342,10 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
if(res == CURLE_AGAIN)
return CURLE_OK; /* return */
-#ifdef CURL_DOES_CONVERSIONS
- if((res == CURLE_OK) && (gotbytes > 0)) {
+ if((res == CURLE_OK) && (gotbytes > 0))
/* convert from the network encoding */
res = Curl_convert_from_network(data, ptr, gotbytes);
- /* Curl_convert_from_network calls failf if unsuccessful */
- }
-#endif /* CURL_DOES_CONVERSIONS */
+ /* Curl_convert_from_network calls failf if unsuccessful */
if(CURLE_OK != res) {
result = (CURLcode)res; /* Set outer result variable to this error. */
diff --git a/lib/pop3.c b/lib/pop3.c
index 79af8fc0c..8f37c1fe6 100644
--- a/lib/pop3.c
+++ b/lib/pop3.c
@@ -65,8 +65,6 @@
#include <curl/curl.h>
#include "urldata.h"
#include "sendf.h"
-#include "easyif.h" /* for Curl_convert_... prototypes */
-
#include "if2ip.h"
#include "hostip.h"
#include "progress.h"
diff --git a/lib/rtsp.c b/lib/rtsp.c
index 56998c16e..14f430c88 100644
--- a/lib/rtsp.c
+++ b/lib/rtsp.c
@@ -28,7 +28,6 @@
#include <curl/curl.h>
#include "transfer.h"
#include "sendf.h"
-#include "easyif.h" /* for Curl_convert_... prototypes */
#include "multiif.h"
#include "http.h"
#include "url.h"
diff --git a/lib/sendf.c b/lib/sendf.c
index ab79a8080..06b289cbc 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -43,6 +43,7 @@
#include "ssh.h"
#include "multiif.h"
#include "rtsp.h"
+#include "non-ascii.h"
#define _MPRINTF_REPLACE /* use the internal *printf() functions */
#include <curl/mprintf.h>
@@ -58,7 +59,7 @@
#include <string.h>
#include "curl_memory.h"
#include "strerror.h"
-#include "easyif.h" /* for the Curl_convert_from_network prototype */
+
/* The last #include file should be: */
#include "memdebug.h"
@@ -443,14 +444,11 @@ CURLcode Curl_client_write(struct connectdata *conn,
if(type & CLIENTWRITE_BODY) {
if((conn->handler->protocol&CURLPROTO_FTP) &&
conn->proto.ftpc.transfertype == 'A') {
-#ifdef CURL_DOES_CONVERSIONS
/* convert from the network encoding */
- size_t rc;
- rc = Curl_convert_from_network(data, ptr, len);
+ size_t rc = Curl_convert_from_network(data, ptr, len);
/* Curl_convert_from_network calls failf if unsuccessful */
- if(rc != CURLE_OK)
+ if(rc)
return rc;
-#endif /* CURL_DOES_CONVERSIONS */
#ifdef CURL_DO_LINEEND_CONV
/* convert end-of-line markers */
diff --git a/lib/smtp.c b/lib/smtp.c
index 1680a82e1..e14c25f50 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -67,8 +67,6 @@
#include <curl/curl.h>
#include "urldata.h"
#include "sendf.h"
-#include "easyif.h" /* for Curl_convert_... prototypes */
-
#include "if2ip.h"
#include "hostip.h"
#include "progress.h"
diff --git a/lib/ssh.c b/lib/ssh.c
index f760d84ba..04219d8f1 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -79,8 +79,6 @@
#include <curl/curl.h>
#include "urldata.h"
#include "sendf.h"
-#include "easyif.h" /* for Curl_convert_... prototypes */
-
#include "hostip.h"
#include "progress.h"
#include "transfer.h"
diff --git a/lib/ssluse.c b/lib/ssluse.c
index eb022ad93..9d55eb0c3 100644
--- a/lib/ssluse.c
+++ b/lib/ssluse.c
@@ -71,7 +71,7 @@
#endif
#include "curl_memory.h"
-#include "easyif.h" /* for Curl_convert_from_utf8 prototype */
+#include "non-ascii.h" /* for Curl_convert_from_utf8 prototype */
/* The last #include file should be: */
#include "memdebug.h"
@@ -1251,18 +1251,15 @@ static CURLcode verifyhost(struct connectdata *conn,
if(peer_CN == nulstr)
peer_CN = NULL;
-#ifdef CURL_DOES_CONVERSIONS
else {
/* convert peer_CN from UTF8 */
- size_t rc;
- rc = Curl_convert_from_utf8(data, peer_CN, strlen(peer_CN));
+ size_t rc = Curl_convert_from_utf8(data, peer_CN, strlen(peer_CN));
/* Curl_convert_from_utf8 calls failf if unsuccessful */
- if(rc != CURLE_OK) {
+ if(rc) {
OPENSSL_free(peer_CN);
return rc;
}
}
-#endif /* CURL_DOES_CONVERSIONS */
if(res)
/* error already detected, pass through */
diff --git a/lib/transfer.c b/lib/transfer.c
index 960056c1d..08d5ed37f 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -101,7 +101,6 @@
#include "curl_memory.h"
#include "select.h"
#include "multiif.h"
-#include "easyif.h" /* for Curl_convert_to_network prototype */
#include "rtsp.h"
#include "connect.h"
diff --git a/lib/url.c b/lib/url.c
index cf576ad8a..3bc8db06d 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -122,6 +122,7 @@ int curl_win32_idn_to_ascii(const char *in, char **out);
#include "speedcheck.h"
#include "rawstr.h"
#include "warnless.h"
+#include "non-ascii.h"
/* And now for the protocols */
#include "ftp.h"
@@ -527,18 +528,7 @@ CURLcode Curl_close(struct SessionHandle *data)
/* this destroys the channel and we cannot use it anymore after this */
ares_destroy(data->state.areschannel);
-#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
- /* close iconv conversion descriptors */
- if(data->inbound_cd != (iconv_t)-1) {
- iconv_close(data->inbound_cd);
- }
- if(data->outbound_cd != (iconv_t)-1) {
- iconv_close(data->outbound_cd);
- }
- if(data->utf8_cd != (iconv_t)-1) {
- iconv_close(data->utf8_cd);
- }
-#endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */
+ Curl_convert_close(data);
/* No longer a dirty share, if it exists */
if(data->share) {
@@ -816,12 +806,7 @@ CURLcode Curl_open(struct SessionHandle **curl)
data->state.headersize=HEADERSIZE;
-#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
- /* conversion descriptors for iconv calls */
- data->outbound_cd = (iconv_t)-1;
- data->inbound_cd = (iconv_t)-1;
- data->utf8_cd = (iconv_t)-1;
-#endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */
+ Curl_convert_init(data);
/* most recent connection is not yet defined */
data->state.lastconnect = -1;