653
668
data->set.ssl.CAfile = (char *)CURL_CA_BUNDLE;
672
#ifdef CURL_DOES_CONVERSIONS
674
* Curl_convert_to_network() is an internal function
675
* for performing ASCII conversions on non-ASCII platforms.
677
CURLcode Curl_convert_to_network(struct SessionHandle *data,
678
char *buffer, size_t length)
682
if(data->set.convtonetwork) {
683
/* use translation callback */
684
rc = data->set.convtonetwork(buffer, length);
687
"CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %i: %s",
688
rc, curl_easy_strerror(rc));
693
/* do the translation ourselves */
694
char *input_ptr, *output_ptr;
695
size_t in_bytes, out_bytes, rc;
697
/* open an iconv conversion descriptor if necessary */
698
if(data->outbound_cd == (iconv_t)-1) {
699
data->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
700
CURL_ICONV_CODESET_OF_HOST);
701
if(data->outbound_cd == (iconv_t)-1) {
703
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
704
CURL_ICONV_CODESET_OF_NETWORK,
705
CURL_ICONV_CODESET_OF_HOST,
706
errno, strerror(errno));
707
return CURLE_CONV_FAILED;
711
input_ptr = output_ptr = buffer;
712
in_bytes = out_bytes = length;
713
rc = iconv(data->outbound_cd, &input_ptr, &in_bytes,
714
&output_ptr, &out_bytes);
715
if ((rc == -1) || (in_bytes != 0)) {
717
"The Curl_convert_to_network iconv call failed with errno %i: %s",
718
errno, strerror(errno));
719
return CURLE_CONV_FAILED;
722
failf(data, "CURLOPT_CONV_TO_NETWORK_FUNCTION callback required");
723
return CURLE_CONV_REQD;
724
#endif /* HAVE_ICONV */
731
* Curl_convert_from_network() is an internal function
732
* for performing ASCII conversions on non-ASCII platforms.
734
CURLcode Curl_convert_from_network(struct SessionHandle *data,
735
char *buffer, size_t length)
739
if(data->set.convfromnetwork) {
740
/* use translation callback */
741
rc = data->set.convfromnetwork(buffer, length);
744
"CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %i: %s",
745
rc, curl_easy_strerror(rc));
750
/* do the translation ourselves */
751
char *input_ptr, *output_ptr;
752
size_t in_bytes, out_bytes, rc;
754
/* open an iconv conversion descriptor if necessary */
755
if(data->inbound_cd == (iconv_t)-1) {
756
data->inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
757
CURL_ICONV_CODESET_OF_NETWORK);
758
if(data->inbound_cd == (iconv_t)-1) {
760
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
761
CURL_ICONV_CODESET_OF_HOST,
762
CURL_ICONV_CODESET_OF_NETWORK,
763
errno, strerror(errno));
764
return CURLE_CONV_FAILED;
768
input_ptr = output_ptr = buffer;
769
in_bytes = out_bytes = length;
770
rc = iconv(data->inbound_cd, &input_ptr, &in_bytes,
771
&output_ptr, &out_bytes);
772
if ((rc == -1) || (in_bytes != 0)) {
774
"The Curl_convert_from_network iconv call failed with errno %i: %s",
775
errno, strerror(errno));
776
return CURLE_CONV_FAILED;
779
failf(data, "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback required");
780
return CURLE_CONV_REQD;
781
#endif /* HAVE_ICONV */
788
* Curl_convert_from_utf8() is an internal function
789
* for performing UTF-8 conversions on non-ASCII platforms.
791
CURLcode Curl_convert_from_utf8(struct SessionHandle *data,
792
char *buffer, size_t length)
796
if(data->set.convfromutf8) {
797
/* use translation callback */
798
rc = data->set.convfromutf8(buffer, length);
801
"CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %i: %s",
802
rc, curl_easy_strerror(rc));
807
/* do the translation ourselves */
808
char *input_ptr, *output_ptr;
809
size_t in_bytes, out_bytes, rc;
811
/* open an iconv conversion descriptor if necessary */
812
if(data->utf8_cd == (iconv_t)-1) {
813
data->utf8_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
814
CURL_ICONV_CODESET_FOR_UTF8);
815
if(data->utf8_cd == (iconv_t)-1) {
817
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
818
CURL_ICONV_CODESET_OF_HOST,
819
CURL_ICONV_CODESET_FOR_UTF8,
820
errno, strerror(errno));
821
return CURLE_CONV_FAILED;
825
input_ptr = output_ptr = buffer;
826
in_bytes = out_bytes = length;
827
rc = iconv(data->utf8_cd, &input_ptr, &in_bytes, &output_ptr, &out_bytes);
828
if ((rc == -1) || (in_bytes != 0)) {
830
"The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
831
errno, strerror(errno));
832
return CURLE_CONV_FAILED;
834
if (output_ptr < input_ptr) {
835
/* null terminate the now shorter output string */
839
failf(data, "CURLOPT_CONV_FROM_UTF8_FUNCTION callback required");
840
return CURLE_CONV_REQD;
841
#endif /* HAVE_ICONV */
847
#endif /* CURL_DOES_CONVERSIONS */