lib: remove support for CURL_DOES_CONVERSIONS

TPF was the only user and support for that was dropped.

Closes #8378
This commit is contained in:
Daniel Stenberg 2022-02-03 13:04:30 +01:00
parent da15443ddd
commit 2610142139
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
95 changed files with 198 additions and 1907 deletions

View file

@ -59,7 +59,6 @@ CURL_CFILES = \
tool_cb_see.c \
tool_cb_wrt.c \
tool_cfgable.c \
tool_convert.c \
tool_dirhie.c \
tool_doswin.c \
tool_easysrc.c \
@ -102,7 +101,6 @@ CURL_HFILES = \
tool_cb_see.h \
tool_cb_wrt.h \
tool_cfgable.h \
tool_convert.h \
tool_dirhie.h \
tool_doswin.h \
tool_easysrc.h \

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2022, 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
@ -26,7 +26,6 @@
#include "curlx.h"
#include "tool_cfgable.h"
#include "tool_convert.h"
#include "tool_msgs.h"
#include "tool_cb_dbg.h"
#include "tool_util.h"
@ -162,29 +161,6 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
return 0;
}
#ifdef CURL_DOES_CONVERSIONS
/* Special processing is needed for CURLINFO_HEADER_OUT blocks
* if they contain both headers and data (separated by CRLFCRLF).
* We dump the header text and then switch type to CURLINFO_DATA_OUT.
*/
if((type == CURLINFO_HEADER_OUT) && (size > 4)) {
size_t i;
for(i = 0; i < size - 4; i++) {
if(memcmp(&data[i], "\r\n\r\n", 4) == 0) {
/* dump everything through the CRLFCRLF as a sent header */
text = "=> Send header";
dump(timebuf, text, output, (unsigned char *)data, i + 4,
config->tracetype, type);
data += i + 3;
size -= i + 4;
type = CURLINFO_DATA_OUT;
data += 1;
break;
}
}
}
#endif /* CURL_DOES_CONVERSIONS */
switch(type) {
case CURLINFO_TEXT:
fprintf(output, "%s== Info: %.*s", timebuf, (int)size, data);
@ -253,21 +229,9 @@ static void dump(const char *timebuf, const char *text,
i += (c + 2 - width);
break;
}
#ifdef CURL_DOES_CONVERSIONS
/* repeat the 0D0A check above but use the host encoding for CRLF */
if((tracetype == TRACE_ASCII) &&
(i + c + 1 < size) && (ptr[i + c] == '\r') &&
(ptr[i + c + 1] == '\n')) {
i += (c + 2 - width);
break;
}
/* convert to host encoding and print this character */
fprintf(stream, "%c", convert_char(infotype, ptr[i + c]));
#else
(void)infotype;
fprintf(stream, "%c", ((ptr[i + c] >= 0x20) && (ptr[i + c] < 0x80)) ?
ptr[i + c] : UNPRINTABLE_CHAR);
#endif /* CURL_DOES_CONVERSIONS */
/* check again for 0D0A, to avoid an extra \n if it's at width */
if((tracetype == TRACE_ASCII) &&
(i + c + 2 < size) && (ptr[i + c + 1] == 0x0D) &&

View file

@ -1,147 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, 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 https://curl.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 "tool_setup.h"
#ifdef CURL_DOES_CONVERSIONS
#ifdef HAVE_ICONV
# include <iconv.h>
#endif
#include "tool_convert.h"
#include "memdebug.h" /* keep this as LAST include */
#ifdef HAVE_ICONV
/* curl tool iconv conversion descriptors */
static iconv_t inbound_cd = (iconv_t)-1;
static iconv_t outbound_cd = (iconv_t)-1;
/* set default codesets for iconv */
#ifndef CURL_ICONV_CODESET_OF_NETWORK
# define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1"
#endif
/*
* convert_to_network() is a curl tool function to convert
* from the host encoding to ASCII on non-ASCII platforms.
*/
CURLcode convert_to_network(char *buffer, size_t length)
{
/* translate from the host encoding to the network encoding */
char *input_ptr, *output_ptr;
size_t res, in_bytes, out_bytes;
/* open an iconv conversion descriptor if necessary */
if(outbound_cd == (iconv_t)-1) {
outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
CURL_ICONV_CODESET_OF_HOST);
if(outbound_cd == (iconv_t)-1) {
return CURLE_CONV_FAILED;
}
}
/* call iconv */
input_ptr = output_ptr = buffer;
in_bytes = out_bytes = length;
res = iconv(outbound_cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if((res == (size_t)-1) || (in_bytes)) {
return CURLE_CONV_FAILED;
}
return CURLE_OK;
}
/*
* convert_from_network() is a curl tool function
* for performing ASCII conversions on non-ASCII platforms.
*/
CURLcode convert_from_network(char *buffer, size_t length)
{
/* translate from the network encoding to the host encoding */
char *input_ptr, *output_ptr;
size_t res, in_bytes, out_bytes;
/* open an iconv conversion descriptor if necessary */
if(inbound_cd == (iconv_t)-1) {
inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_OF_NETWORK);
if(inbound_cd == (iconv_t)-1) {
return CURLE_CONV_FAILED;
}
}
/* call iconv */
input_ptr = output_ptr = buffer;
in_bytes = out_bytes = length;
res = iconv(inbound_cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if((res == (size_t)-1) || (in_bytes)) {
return CURLE_CONV_FAILED;
}
return CURLE_OK;
}
void convert_cleanup(void)
{
/* close iconv conversion descriptors */
if(inbound_cd != (iconv_t)-1)
(void)iconv_close(inbound_cd);
if(outbound_cd != (iconv_t)-1)
(void)iconv_close(outbound_cd);
}
#endif /* HAVE_ICONV */
char convert_char(curl_infotype infotype, char this_char)
{
/* determine how this specific character should be displayed */
switch(infotype) {
case CURLINFO_DATA_IN:
case CURLINFO_DATA_OUT:
case CURLINFO_SSL_DATA_IN:
case CURLINFO_SSL_DATA_OUT:
/* data, treat as ASCII */
if(this_char < 0x20 || this_char >= 0x7f) {
/* non-printable ASCII, use a replacement character */
return UNPRINTABLE_CHAR;
}
/* printable ASCII hex value: convert to host encoding */
(void)convert_from_network(&this_char, 1);
/* FALLTHROUGH */
default:
/* treat as host encoding */
if(ISPRINT(this_char)
&& (this_char != '\t')
&& (this_char != '\r')
&& (this_char != '\n')) {
/* printable characters excluding tabs and line end characters */
return this_char;
}
break;
}
/* non-printable, use a replacement character */
return UNPRINTABLE_CHAR;
}
#endif /* CURL_DOES_CONVERSIONS */

View file

@ -1,44 +0,0 @@
#ifndef HEADER_CURL_TOOL_CONVERT_H
#define HEADER_CURL_TOOL_CONVERT_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, 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 https://curl.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 "tool_setup.h"
#ifdef CURL_DOES_CONVERSIONS
#ifdef HAVE_ICONV
CURLcode convert_to_network(char *buffer, size_t length);
CURLcode convert_from_network(char *buffer, size_t length);
void convert_cleanup(void);
#endif /* HAVE_ICONV */
char convert_char(curl_infotype infotype, char this_char);
#endif /* CURL_DOES_CONVERSIONS */
#if !defined(CURL_DOES_CONVERSIONS) || !defined(HAVE_ICONV)
#define convert_cleanup() Curl_nop_stmt
#endif
#endif /* HEADER_CURL_TOOL_CONVERT_H */

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2022, 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
@ -28,7 +28,6 @@
#include "curlx.h"
#include "tool_cfgable.h"
#include "tool_convert.h"
#include "tool_msgs.h"
#include "tool_binmode.h"
#include "tool_getparam.h"
@ -268,25 +267,7 @@ static CURLcode tool2curlparts(CURL *curl, struct tool_mime *m,
break;
case TOOLMIME_DATA:
#ifdef CURL_DOES_CONVERSIONS
/* Our data is always textual: convert it to ASCII. */
{
size_t size = strlen(m->data);
char *cp = malloc(size + 1);
if(!cp)
ret = CURLE_OUT_OF_MEMORY;
else {
memcpy(cp, m->data, size + 1);
ret = convert_to_network(cp, size);
if(!ret)
ret = curl_mime_data(part, cp, CURL_ZERO_TERMINATED);
free(cp);
}
}
#else
ret = curl_mime_data(part, m->data, CURL_ZERO_TERMINATED);
#endif
break;
case TOOLMIME_FILE:

View file

@ -30,7 +30,6 @@
#include "tool_binmode.h"
#include "tool_cfgable.h"
#include "tool_cb_prg.h"
#include "tool_convert.h"
#include "tool_filetime.h"
#include "tool_formparse.h"
#include "tool_getparam.h"
@ -1521,16 +1520,6 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
if(subletter == 'f')
config->jsoned = TRUE;
#ifdef CURL_DOES_CONVERSIONS
if(subletter != 'b') {
/* NOT forced binary, convert to ASCII */
if(convert_to_network(postdata, strlen(postdata))) {
Curl_safefree(postdata);
return PARAM_NO_MEM;
}
}
#endif
if(config->postfields) {
/* we already have a string, we append this one with a separating
&-letter */

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2022, 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
@ -41,7 +41,6 @@
#include "curlx.h"
#include "tool_cfgable.h"
#include "tool_convert.h"
#include "tool_doswin.h"
#include "tool_msgs.h"
#include "tool_operate.h"
@ -211,7 +210,6 @@ static void main_free(struct GlobalConfig *config)
/* Cleanup the easy handle */
/* Main cleanup */
curl_global_cleanup();
convert_cleanup();
#ifdef USE_NSS
if(PR_Initialized()) {
/* prevent valgrind from reporting still reachable mem from NSPR arenas */

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2022, 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
@ -28,7 +28,6 @@
#include "curlx.h"
#include "tool_cfgable.h"
#include "tool_convert.h"
#include "tool_doswin.h"
#include "tool_operhlp.h"

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2022, 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
@ -30,7 +30,6 @@
#include "tool_cfgable.h"
#include "tool_easysrc.h"
#include "tool_setopt.h"
#include "tool_convert.h"
#include "tool_msgs.h"
#include "memdebug.h" /* keep this as LAST include */
@ -474,25 +473,7 @@ static CURLcode libcurl_generate_mime_part(CURL *curl,
break;
case TOOLMIME_DATA:
#ifdef CURL_DOES_CONVERSIONS
/* Data will be set in ASCII, thus issue a comment with clear text. */
escaped = c_escape(part->data, ZERO_TERMINATED);
NULL_CHECK(escaped);
CODE1("/* \"%s\" */", escaped);
/* Our data is always textual: convert it to ASCII. */
{
size_t size = strlen(part->data);
char *cp = malloc(size + 1);
NULL_CHECK(cp);
memcpy(cp, part->data, size + 1);
ret = convert_to_network(cp, size);
data = cp;
}
#else
data = part->data;
#endif
if(!ret) {
Curl_safefree(escaped);
escaped = c_escape(data, ZERO_TERMINATED);
@ -566,11 +547,6 @@ static CURLcode libcurl_generate_mime_part(CURL *curl,
}
nomem:
#ifdef CURL_DOES_CONVERSIONS
if(data)
free((char *) data);
#endif
Curl_safefree(escaped);
return ret;
}