mirror of https://github.com/aria2/aria2
2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Applied Ross's aria2-0.13.2+1-mingw-4.patch. In this commit, only the follow sources are applied. * src/Platform.h: I removed HAVE_WINSOCK2_H directive from Platform.h. * src/Platform.cc: Moved common setup/teardown code to Platform class. I moved #endif // HAVE_WINSOCK2_H to the front of #include "DlAbortEx.h" I included locale.h from Platform.cc. * src/main.cc: Moved common setup/teardown code to Platform class. * test/AllTest.cc: Use Platform class. Set locale to C in AllTest.cc to prevent the messages to be localized.pull/1/head
parent
06644332c2
commit
aaa2ecaa6f
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Applied Ross's aria2-0.13.2+1-mingw-4.patch. In this commit, only the
|
||||||
|
follow sources are applied.
|
||||||
|
* src/Platform.h: I removed HAVE_WINSOCK2_H directive from Platform.h.
|
||||||
|
* src/Platform.cc: Moved common setup/teardown code to Platform class.
|
||||||
|
I moved #endif // HAVE_WINSOCK2_H to the front of #include "DlAbortEx.h"
|
||||||
|
I included locale.h from Platform.cc.
|
||||||
|
* src/main.cc: Moved common setup/teardown code to Platform class.
|
||||||
|
* test/AllTest.cc: Use Platform class.
|
||||||
|
Set locale to C in AllTest.cc to prevent the messages to be localized.
|
||||||
|
|
||||||
2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Applied Ross's aria2-0.13.2+1-mingw-3.patch.
|
Applied Ross's aria2-0.13.2+1-mingw-3.patch.
|
||||||
|
|
|
@ -33,6 +33,15 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBSSL
|
||||||
|
# include <openssl/err.h>
|
||||||
|
# include <openssl/ssl.h>
|
||||||
|
#endif // HAVE_LIBSSL
|
||||||
|
#ifdef HAVE_LIBGNUTLS
|
||||||
|
# include <gnutls/gnutls.h>
|
||||||
|
#endif // HAVE_LIBGNUTLS
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
|
|
||||||
#ifndef _WIN32_WINNT
|
#ifndef _WIN32_WINNT
|
||||||
|
@ -44,26 +53,87 @@
|
||||||
# include <ws2tcpip.h>
|
# include <ws2tcpip.h>
|
||||||
#endif // HAVE_WS2TCPIP_H
|
#endif // HAVE_WS2TCPIP_H
|
||||||
|
|
||||||
|
#endif // HAVE_WINSOCK2_H
|
||||||
|
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include <stdlib.h> /* _fmode */
|
#include <stdlib.h> /* _fmode */
|
||||||
#include <fcntl.h> /* _O_BINARY */
|
#include <fcntl.h> /* _O_BINARY */
|
||||||
|
#include <locale.h> // For setlocale, LC_*
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
Platform::Platform() {
|
bool Platform::_initialized = false;
|
||||||
unsigned int _CRT_fmode = _O_BINARY;
|
|
||||||
|
Platform::Platform()
|
||||||
|
{
|
||||||
|
setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform::~Platform()
|
||||||
|
{
|
||||||
|
tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Platform::setUp()
|
||||||
|
{
|
||||||
|
if (_initialized) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_initialized = true;
|
||||||
|
|
||||||
|
#ifdef ENABLE_NLS
|
||||||
|
setlocale (LC_CTYPE, "");
|
||||||
|
setlocale (LC_MESSAGES, "");
|
||||||
|
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
|
textdomain (PACKAGE);
|
||||||
|
#endif // ENABLE_NLS
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBSSL
|
||||||
|
// for SSL initialization
|
||||||
|
SSL_load_error_strings();
|
||||||
|
SSL_library_init();
|
||||||
|
#endif // HAVE_LIBSSL
|
||||||
|
#ifdef HAVE_LIBGNUTLS
|
||||||
|
gnutls_global_init();
|
||||||
|
#endif // HAVE_LIBGNUTLS
|
||||||
|
|
||||||
|
#ifdef HAVE_WINSOCK2_H
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
memset((char*)&wsaData, 0, sizeof(wsaData));
|
memset((char*)&wsaData, 0, sizeof(wsaData));
|
||||||
if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
|
if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
|
||||||
throw DlAbortEx(MSG_WINSOCK_INIT_FAILD);
|
throw DlAbortEx(MSG_WINSOCK_INIT_FAILD);
|
||||||
}
|
}
|
||||||
|
#endif // HAVE_WINSOCK2_H
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
unsigned int _CRT_fmode = _O_BINARY;
|
||||||
|
#endif // __MINGW32__
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Platform::~Platform() {
|
bool Platform::tearDown()
|
||||||
|
{
|
||||||
|
if (!_initialized) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_initialized = false;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBGNUTLS
|
||||||
|
gnutls_global_deinit();
|
||||||
|
#endif // HAVE_LIBGNUTLS
|
||||||
|
|
||||||
|
#ifdef HAVE_WINSOCK2_H
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
|
#endif // HAVE_WINSOCK2_H
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Platform::isInitialized()
|
||||||
|
{
|
||||||
|
return _initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
#endif // HAVE_WINSOCK2_H
|
|
||||||
|
|
|
@ -39,16 +39,21 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
|
||||||
|
|
||||||
class Platform {
|
class Platform {
|
||||||
|
private:
|
||||||
|
static bool _initialized;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Platform();
|
Platform();
|
||||||
|
|
||||||
~Platform();
|
~Platform();
|
||||||
};
|
|
||||||
|
|
||||||
#endif // HAVE_WINSOCK2_H
|
static bool setUp();
|
||||||
|
|
||||||
|
static bool tearDown();
|
||||||
|
|
||||||
|
static bool isInitialized();
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
31
src/main.cc
31
src/main.cc
|
@ -85,15 +85,6 @@ extern char* optarg;
|
||||||
extern int optind, opterr, optopt;
|
extern int optind, opterr, optopt;
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
#ifdef HAVE_LIBSSL
|
|
||||||
// for SSL
|
|
||||||
# include <openssl/err.h>
|
|
||||||
# include <openssl/ssl.h>
|
|
||||||
#endif // HAVE_LIBSSL
|
|
||||||
#ifdef HAVE_LIBGNUTLS
|
|
||||||
# include <gnutls/gnutls.h>
|
|
||||||
#endif // HAVE_LIBGNUTLS
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
// output stream to /dev/null
|
// output stream to /dev/null
|
||||||
|
@ -460,31 +451,9 @@ int main(int argc, char* argv[])
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
#ifdef HAVE_WINSOCK2_H
|
|
||||||
aria2::Platform platform;
|
aria2::Platform platform;
|
||||||
#endif // HAVE_WINSOCK2_H
|
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
|
||||||
setlocale (LC_CTYPE, "");
|
|
||||||
setlocale (LC_MESSAGES, "");
|
|
||||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
|
||||||
textdomain (PACKAGE);
|
|
||||||
#endif // ENABLE_NLS
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBSSL
|
|
||||||
// for SSL initialization
|
|
||||||
SSL_load_error_strings();
|
|
||||||
SSL_library_init();
|
|
||||||
#endif // HAVE_LIBSSL
|
|
||||||
#ifdef HAVE_LIBGNUTLS
|
|
||||||
gnutls_global_init();
|
|
||||||
#endif // HAVE_LIBGNUTLS
|
|
||||||
|
|
||||||
int r = aria2::main(argc, argv);
|
int r = aria2::main(argc, argv);
|
||||||
|
|
||||||
#ifdef HAVE_LIBGNUTLS
|
|
||||||
gnutls_global_deinit();
|
|
||||||
#endif // HAVE_LIBGNUTLS
|
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
|
#include "Platform.h"
|
||||||
#include "CookieBoxFactory.h"
|
#include "CookieBoxFactory.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cppunit/CompilerOutputter.h>
|
#include <cppunit/CompilerOutputter.h>
|
||||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||||
#include <cppunit/ui/text/TestRunner.h>
|
#include <cppunit/ui/text/TestRunner.h>
|
||||||
#ifdef HAVE_LIBSSL
|
|
||||||
# include <openssl/err.h>
|
|
||||||
# include <openssl/ssl.h>
|
|
||||||
#endif // HAVE_LIBSSL
|
|
||||||
#ifdef HAVE_LIBGNUTLS
|
|
||||||
# include <gnutls/gnutls.h>
|
|
||||||
#endif // HAVE_LIBGNUTLS
|
|
||||||
|
|
||||||
using aria2::SharedHandle;
|
using aria2::SharedHandle;
|
||||||
using aria2::SingletonHolder;
|
using aria2::SingletonHolder;
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
aria2::Platform platform;
|
||||||
|
|
||||||
|
#ifdef ENABLE_NLS
|
||||||
|
// Set locale to C to prevent the messages to be localized.
|
||||||
|
setlocale (LC_CTYPE, "C");
|
||||||
|
setlocale (LC_MESSAGES, "C");
|
||||||
|
#endif // ENABLE_NLS
|
||||||
|
|
||||||
CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
|
CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
|
||||||
CppUnit::TextUi::TestRunner runner;
|
CppUnit::TextUi::TestRunner runner;
|
||||||
runner.addTest(suite);
|
runner.addTest(suite);
|
||||||
|
@ -23,15 +25,6 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
|
|
||||||
#ifdef HAVE_LIBSSL
|
|
||||||
// for SSL initialization
|
|
||||||
SSL_load_error_strings();
|
|
||||||
SSL_library_init();
|
|
||||||
#endif // HAVE_LIBSSL
|
|
||||||
#ifdef HAVE_LIBGNUTLS
|
|
||||||
gnutls_global_init();
|
|
||||||
#endif // HAVE_LIBGNUTLS
|
|
||||||
|
|
||||||
SharedHandle<aria2::CookieBoxFactory> cookieBoxFactory
|
SharedHandle<aria2::CookieBoxFactory> cookieBoxFactory
|
||||||
(new aria2::CookieBoxFactory());
|
(new aria2::CookieBoxFactory());
|
||||||
SingletonHolder<SharedHandle<aria2::CookieBoxFactory> >::instance(cookieBoxFactory);
|
SingletonHolder<SharedHandle<aria2::CookieBoxFactory> >::instance(cookieBoxFactory);
|
||||||
|
@ -39,9 +32,5 @@ int main(int argc, char* argv[]) {
|
||||||
// Run the tests.
|
// Run the tests.
|
||||||
bool successfull = runner.run();
|
bool successfull = runner.run();
|
||||||
|
|
||||||
#ifdef HAVE_LIBGNUTLS
|
|
||||||
gnutls_global_deinit();
|
|
||||||
#endif // HAVE_LIBGNUTLS
|
|
||||||
|
|
||||||
return successfull ? 0 : 1;
|
return successfull ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue