1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 15:48:49 -05:00

CURL_DOES_CONVERSIONS: cleanup

Massively reduce #ifdefs all over (23 #ifdef lines less so far)
Moved conversion-specific code to non-ascii.c
This commit is contained in:
Daniel Stenberg 2011-04-20 00:48:20 +02:00
parent eb65a49bef
commit c828646f60
25 changed files with 469 additions and 420 deletions

View File

@ -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

View File

@ -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 ---- */

View File

@ -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,

View File

@ -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 */

View File

@ -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;

View File

@ -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.

View File

@ -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)

View File

@ -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 &&

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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)

View File

@ -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"

332
lib/non-ascii.c Normal file
View File

@ -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 */

60
lib/non-ascii.h Normal file
View File

@ -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

View File

@ -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"

View File

@ -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. */

View File

@ -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"

View File

@ -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"

View File

@ -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 */

View File

@ -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"

View File

@ -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"

View File

@ -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 */

View File

@ -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"

View File

@ -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;