25 #ifdef CURL_DOES_CONVERSIONS 41 #ifndef CURL_ICONV_CODESET_OF_NETWORK 42 #define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1" 44 #ifndef CURL_ICONV_CODESET_FOR_UTF8 45 #define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8" 47 #define ICONV_ERROR (size_t)-1 66 memcpy(convbuf, indata, insize);
83 char *
buffer,
size_t length)
90 "CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %d: %s",
99 iconv_t tmpcd = (iconv_t) -1;
100 iconv_t *cd = &tmpcd;
101 char *input_ptr, *output_ptr;
102 size_t in_bytes, out_bytes,
rc;
106 cd = &data->outbound_cd;
107 if(*cd == (iconv_t)-1) {
108 *cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
110 if(*cd == (iconv_t)-1) {
112 "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
113 CURL_ICONV_CODESET_OF_NETWORK,
115 errno, strerror(errno));
120 input_ptr = output_ptr =
buffer;
121 in_bytes = out_bytes = length;
122 rc = iconv(*cd, &input_ptr, &in_bytes,
123 &output_ptr, &out_bytes);
126 if((rc == ICONV_ERROR) || (in_bytes != 0)) {
128 "The Curl_convert_to_network iconv call failed with errno %i: %s",
129 errno, strerror(errno));
133 failf(data,
"CURLOPT_CONV_TO_NETWORK_FUNCTION callback required");
146 char *buffer,
size_t length)
153 "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %d: %s",
162 iconv_t tmpcd = (iconv_t) -1;
163 iconv_t *cd = &tmpcd;
164 char *input_ptr, *output_ptr;
165 size_t in_bytes, out_bytes,
rc;
169 cd = &data->inbound_cd;
170 if(*cd == (iconv_t)-1) {
172 CURL_ICONV_CODESET_OF_NETWORK);
173 if(*cd == (iconv_t)-1) {
175 "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
177 CURL_ICONV_CODESET_OF_NETWORK,
178 errno, strerror(errno));
183 input_ptr = output_ptr =
buffer;
184 in_bytes = out_bytes = length;
185 rc = iconv(*cd, &input_ptr, &in_bytes,
186 &output_ptr, &out_bytes);
189 if((rc == ICONV_ERROR) || (in_bytes != 0)) {
191 "Curl_convert_from_network iconv call failed with errno %i: %s",
192 errno, strerror(errno));
196 failf(data,
"CURLOPT_CONV_FROM_NETWORK_FUNCTION callback required");
209 char *buffer,
size_t length)
216 "CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %d: %s",
225 iconv_t tmpcd = (iconv_t) -1;
226 iconv_t *cd = &tmpcd;
229 size_t in_bytes, out_bytes,
rc;
234 if(*cd == (iconv_t)-1) {
236 CURL_ICONV_CODESET_FOR_UTF8);
237 if(*cd == (iconv_t)-1) {
239 "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
241 CURL_ICONV_CODESET_FOR_UTF8,
242 errno, strerror(errno));
247 input_ptr = output_ptr =
buffer;
248 in_bytes = out_bytes = length;
249 rc = iconv(*cd, &input_ptr, &in_bytes,
250 &output_ptr, &out_bytes);
253 if((rc == ICONV_ERROR) || (in_bytes != 0)) {
255 "The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
256 errno, strerror(errno));
259 if(output_ptr < input_ptr) {
264 failf(data,
"CURLOPT_CONV_FROM_UTF8_FUNCTION callback required");
277 #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV) 279 data->outbound_cd = (iconv_t)-1;
280 data->inbound_cd = (iconv_t)-1;
281 data->utf8_cd = (iconv_t)-1;
293 CURL_ICONV_CODESET_OF_NETWORK);
294 data->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
297 CURL_ICONV_CODESET_FOR_UTF8);
308 if(data->inbound_cd != (iconv_t)-1) {
309 iconv_close(data->inbound_cd);
311 if(data->outbound_cd != (iconv_t)-1) {
312 iconv_close(data->outbound_cd);
314 if(data->utf8_cd != (iconv_t)-1) {
315 iconv_close(data->utf8_cd);
CURLcode Curl_convert_clone(struct Curl_easy *data, const char *indata, size_t insize, char **outbuf)
#define CURL_ICONV_CODESET_OF_HOST
curl_conv_callback convtonetwork
UNITTEST_START int result
memcpy(filename, filename1, strlen(filename1))
static struct input indata[NUM_HANDLES]
#define Curl_convert_from_network(a, b, c)
#define Curl_convert_to_network(a, b, c)
curl_conv_callback convfromutf8
#define Curl_convert_from_utf8(a, b, c)
#define Curl_convert_close(x)
CURL_EXTERN const char * curl_easy_strerror(CURLcode)
#define Curl_convert_init(x)
curl_conv_callback convfromnetwork
#define Curl_convert_setup(x)