mirror of https://github.com/aria2/aria2
Use _setmode to set binary mode in mingw
The _CRT_fmode stuff was never working correctly anyway, and is entirely unsupported in mingw-w64 these days, it seems.pull/235/head
parent
3c55400d23
commit
d2e38aab36
|
@ -343,7 +343,7 @@ bool AppleTLSContext::tryAsPKCS12(const std::string& certfile)
|
||||||
{
|
{
|
||||||
#if defined(__MAC_10_6)
|
#if defined(__MAC_10_6)
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
BufferedFile(certfile.c_str(), "rb").transfer(ss);
|
BufferedFile(certfile.c_str(), BufferedFile::READ).transfer(ss);
|
||||||
auto data = ss.str();
|
auto data = ss.str();
|
||||||
if (data.empty()) {
|
if (data.empty()) {
|
||||||
A2_LOG_ERROR("Couldn't read certificate file.");
|
A2_LOG_ERROR("Couldn't read certificate file.");
|
||||||
|
|
|
@ -110,7 +110,7 @@ bool GnuTLSContext::addCredentialFile(const std::string& certfile,
|
||||||
bool GnuTLSContext::addP12CredentialFile(const std::string& p12file)
|
bool GnuTLSContext::addP12CredentialFile(const std::string& p12file)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
BufferedFile(p12file.c_str(), "rb").transfer(ss);
|
BufferedFile(p12file.c_str(), BufferedFile::READ).transfer(ss);
|
||||||
auto datastr = ss.str();
|
auto datastr = ss.str();
|
||||||
const gnutls_datum_t data = {
|
const gnutls_datum_t data = {
|
||||||
(unsigned char*)datastr.c_str(),
|
(unsigned char*)datastr.c_str(),
|
||||||
|
|
|
@ -156,7 +156,7 @@ bool OpenSSLTLSContext::addCredentialFile(const std::string& certfile,
|
||||||
bool OpenSSLTLSContext::addP12CredentialFile(const std::string& p12file)
|
bool OpenSSLTLSContext::addP12CredentialFile(const std::string& p12file)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
BufferedFile(p12file.c_str(), "rb").transfer(ss);
|
BufferedFile(p12file.c_str(), BufferedFile::READ).transfer(ss);
|
||||||
|
|
||||||
auto data = ss.str();
|
auto data = ss.str();
|
||||||
void *ptr = const_cast<char*>(data.c_str());
|
void *ptr = const_cast<char*>(data.c_str());
|
||||||
|
|
|
@ -158,7 +158,9 @@ bool Platform::setUp()
|
||||||
#endif // HAVE_WINSOCK2_H
|
#endif // HAVE_WINSOCK2_H
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
unsigned int _CRT_fmode = _O_BINARY;
|
(void)_setmode(_fileno(stdin), _O_BINARY);
|
||||||
|
(void)_setmode(_fileno(stdout), _O_BINARY);
|
||||||
|
(void)_setmode(_fileno(stderr), _O_BINARY);
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue