Enable IndentPPDirectives

pull/1236/head
Tatsuhiro Tsujikawa 2018-06-09 16:23:36 +09:00
parent 6f40026944
commit e0a827ff98
101 changed files with 716 additions and 715 deletions

View File

@ -68,7 +68,7 @@ IncludeCategories:
Priority: 1
IncludeIsMainRegex: '$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentPPDirectives: AfterHash
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave

View File

@ -38,13 +38,13 @@
#include "common.h"
#ifdef USE_INTERNAL_ARC4
#include "InternalARC4Encryptor.h"
# include "InternalARC4Encryptor.h"
#elif HAVE_LIBNETTLE
#include "LibnettleARC4Encryptor.h"
# include "LibnettleARC4Encryptor.h"
#elif HAVE_LIBGCRYPT
#include "LibgcryptARC4Encryptor.h"
# include "LibgcryptARC4Encryptor.h"
#elif HAVE_OPENSSL
#include "LibsslARC4Encryptor.h"
# include "LibsslARC4Encryptor.h"
#endif
#endif // D_ARC4_ENCRYPTOR_H

View File

@ -68,8 +68,8 @@
#include "SocketRecvBuffer.h"
#include "ChecksumCheckIntegrityEntry.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
#include "AsyncNameResolverMan.h"
# include "AsyncNameResolver.h"
# include "AsyncNameResolverMan.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -36,7 +36,7 @@
#include <unistd.h>
#ifdef HAVE_MMAP
#include <sys/mman.h>
# include <sys/mman.h>
#endif // HAVE_MMAP
#include <fcntl.h>
@ -133,17 +133,17 @@ void AbstractDiskWriter::closeFile()
#if defined(HAVE_MMAP) || defined(__MINGW32__)
if (mapaddr_) {
int errNum = 0;
#ifdef __MINGW32__
# ifdef __MINGW32__
if (!UnmapViewOfFile(mapaddr_)) {
errNum = GetLastError();
}
CloseHandle(mapView_);
mapView_ = INVALID_HANDLE_VALUE;
#else // !__MINGW32__
# else // !__MINGW32__
if (munmap(mapaddr_, maplen_) == -1) {
errNum = errno;
}
#endif // !__MINGW32__
# endif // !__MINGW32__
if (errNum != 0) {
int errNum = fileError();
A2_LOG_ERROR(fmt("Unmapping file %s failed: %s", filename_.c_str(),
@ -224,13 +224,13 @@ int openFileWithFlags(const std::string& filename, int flags,
errCode);
}
util::make_fd_cloexec(fd);
#if defined(__APPLE__) && defined(__MACH__)
# if defined(__APPLE__) && defined(__MACH__)
// This may reduce memory consumption on Mac OS X.
fcntl(fd, F_NOCACHE, 1);
#endif // __APPLE__ && __MACH__
# endif // __APPLE__ && __MACH__
return fd;
}
#endif // !__MINGW32__
#endif // !__MINGW32__
} // namespace
void AbstractDiskWriter::openExistingFile(int64_t totalLength)
@ -345,17 +345,17 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
if (mapaddr_) {
if (static_cast<int64_t>(len + offset) > maplen_) {
int errNum = 0;
#ifdef __MINGW32__
# ifdef __MINGW32__
if (!UnmapViewOfFile(mapaddr_)) {
errNum = GetLastError();
}
CloseHandle(mapView_);
mapView_ = INVALID_HANDLE_VALUE;
#else // !__MINGW32__
# else // !__MINGW32__
if (munmap(mapaddr_, maplen_) == -1) {
errNum = errno;
}
#endif // !__MINGW32__
# endif // !__MINGW32__
if (errNum != 0) {
A2_LOG_ERROR(fmt("Unmapping file %s failed: %s", filename_.c_str(),
fileStrerror(errNum).c_str()));
@ -385,7 +385,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
int errNum = 0;
if (static_cast<int64_t>(len + offset) <= filesize) {
#ifdef __MINGW32__
# ifdef __MINGW32__
mapView_ = CreateFileMapping(fd_, 0, PAGE_READWRITE, filesize >> 32,
filesize & 0xffffffffu, 0);
if (mapView_) {
@ -400,7 +400,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
else {
errNum = GetLastError();
}
#else // !__MINGW32__
# else // !__MINGW32__
auto pa =
mmap(nullptr, filesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0);
@ -410,7 +410,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
else {
mapaddr_ = reinterpret_cast<unsigned char*>(pa);
}
#endif // !__MINGW32__
# endif // !__MINGW32__
if (mapaddr_) {
A2_LOG_DEBUG(fmt("Mapping file %s succeeded, length=%" PRId64 "",
filename_.c_str(), static_cast<uint64_t>(filesize)));
@ -517,7 +517,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
return;
}
#ifdef HAVE_SOME_FALLOCATE
#ifdef __MINGW32__
# ifdef __MINGW32__
truncate(offset + length);
if (!SetFileValidData(fd_, offset + length)) {
auto errNum = fileError();
@ -528,7 +528,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
"(see --file-allocation).",
fileStrerror(errNum).c_str()));
}
#elif defined(__APPLE__) && defined(__MACH__)
# elif defined(__APPLE__) && defined(__MACH__)
const auto toalloc = offset + length - size();
fstore_t fstore = {F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE, 0,
toalloc, 0};
@ -546,7 +546,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
}
// This forces the allocation on disk.
ftruncate(fd_, offset + length);
#elif HAVE_FALLOCATE
# elif HAVE_FALLOCATE
// For linux, we use fallocate to detect file system supports
// fallocate or not.
int r;
@ -560,7 +560,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
isDiskFullError(errNum) ? error_code::NOT_ENOUGH_DISK_SPACE
: error_code::FILE_IO_ERROR);
}
#elif HAVE_POSIX_FALLOCATE
# elif HAVE_POSIX_FALLOCATE
int r = posix_fallocate(fd_, offset, length);
if (r != 0) {
throw DL_ABORT_EX3(
@ -569,9 +569,9 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
isDiskFullError(r) ? error_code::NOT_ENOUGH_DISK_SPACE
: error_code::FILE_IO_ERROR);
}
#else
#error "no *_fallocate function available."
#endif
# else
# error "no *_fallocate function available."
# endif
#endif // HAVE_SOME_FALLOCATE
}

View File

@ -41,7 +41,7 @@
#include "WrDiskCacheEntry.h"
#include "LogFactory.h"
#ifdef HAVE_SOME_FALLOCATE
#include "FallocFileAllocationIterator.h"
# include "FallocFileAllocationIterator.h"
#endif // HAVE_SOME_FALLOCATE
namespace aria2 {

View File

@ -40,7 +40,7 @@
#include "Logger.h"
#include "a2functional.h"
#ifdef HAVE_FALLOCATE
#include "FallocFileAllocationIterator.h"
# include "FallocFileAllocationIterator.h"
#endif // HAVE_FALLOCATE
namespace aria2 {

View File

@ -41,7 +41,8 @@ namespace aria2 {
#ifdef HAVE_ZLIB
#define ADLER32_MESSAGE_DIGEST {"adler32", make_hi<Adler32MessageDigestImpl>()},
# define ADLER32_MESSAGE_DIGEST \
{"adler32", make_hi<Adler32MessageDigestImpl>()},
class Adler32MessageDigestImpl : public MessageDigestImpl {
public:
@ -58,7 +59,7 @@ private:
#else // !HAVE_ZLIB
#define ADLER32_MESSAGE_DIGEST
# define ADLER32_MESSAGE_DIGEST
#endif // !HAVE_ZLIB

View File

@ -39,7 +39,7 @@
#include <sstream>
#ifdef __MAC_10_6
#include <Security/SecImportExport.h>
# include <Security/SecImportExport.h>
#endif
#include "LogFactory.h"
@ -55,10 +55,10 @@ using namespace aria2;
#if defined(__MAC_10_6)
#if defined(__MAC_10_7)
# if defined(__MAC_10_7)
static const void* query_keys[] = {kSecClass, kSecReturnRef, kSecMatchPolicy,
kSecMatchLimit};
#endif // defined(__MAC_10_7)
# endif // defined(__MAC_10_7)
template <typename T> class CFRef {
T ref_;
@ -278,7 +278,7 @@ bool AppleTLSContext::tryAsFingerprint(const std::string& fingerprint)
return false;
#else // defined(__MAC_10_7)
#if defined(__MAC_10_6)
# if defined(__MAC_10_6)
CFRef<SecIdentitySearchRef> search;
SecIdentitySearchRef raw_search;
@ -304,14 +304,14 @@ bool AppleTLSContext::tryAsFingerprint(const std::string& fingerprint)
fmt("Failed to lookup %s in your KeyChain", fingerprint.c_str()));
return false;
#else // defined(__MAC_10_6)
# else // defined(__MAC_10_6)
A2_LOG_ERROR("Your system does not support creditials via fingerprints; "
"Upgrade to OSX 10.6 or later");
return false;
#endif // defined(__MAC_10_6)
#endif // defined(__MAC_10_7)
# endif // defined(__MAC_10_6)
#endif // defined(__MAC_10_7)
}
bool AppleTLSContext::tryAsPKCS12(const std::string& certfile)

View File

@ -48,7 +48,7 @@
#define paramErr -50
#ifndef errSSLServerAuthCompleted
#define errSSLServerAuthCompleted -9841
# define errSSLServerAuthCompleted -9841
#endif
namespace {

View File

@ -35,10 +35,10 @@
#include "ConsoleStatCalc.h"
#ifdef HAVE_TERMIOS_H
#include <termios.h>
# include <termios.h>
#endif // HAVE_TERMIOS_H
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
# include <sys/ioctl.h>
#endif // HAVE_SYS_IOCTL_H
#include <unistd.h>
@ -66,9 +66,9 @@
#include "Option.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
#include "PeerStorage.h"
#include "BtRegistry.h"
# include "bittorrent_helper.h"
# include "PeerStorage.h"
# include "BtRegistry.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {
@ -302,19 +302,19 @@ void ConsoleStatCalc::calculateStat(const DownloadEngine* e)
if (isTTY_) {
#ifndef __MINGW32__
#ifdef HAVE_TERMIOS_H
# ifdef HAVE_TERMIOS_H
struct winsize size;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
cols = std::max(0, (int)size.ws_col - 1);
}
#endif // HAVE_TERMIOS_H
#else // __MINGW32__
# endif // HAVE_TERMIOS_H
#else // __MINGW32__
CONSOLE_SCREEN_BUFFER_INFO info;
if (::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE),
&info)) {
cols = std::max(0, info.dwSize.X - 2);
}
#endif // !__MINGW32__
#endif // !__MINGW32__
std::string line(cols, ' ');
global::cout()->printf("\r%s\r", line.c_str());
}

View File

@ -38,7 +38,7 @@
#include <getopt.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
# include <sys/resource.h>
#endif // HAVE_SYS_RESOURCE_H
#include <numeric>
@ -72,11 +72,11 @@
#include "UriListParser.h"
#include "message_digest_helper.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
#ifdef ENABLE_METALINK
#include "metalink_helper.h"
#include "MetalinkEntry.h"
# include "metalink_helper.h"
# include "MetalinkEntry.h"
#endif // ENABLE_METALINK
extern char* optarg;
@ -121,18 +121,18 @@ void showFiles(const std::vector<std::string>& uris,
printf(MSG_SHOW_FILES, (uri).c_str());
printf("\n");
try {
#ifdef ENABLE_BITTORRENT
# ifdef ENABLE_BITTORRENT
if (dt.guessTorrentFile(uri)) {
showTorrentFile(uri);
}
else
#endif // ENABLE_BITTORRENT
#ifdef ENABLE_METALINK
# endif // ENABLE_BITTORRENT
# ifdef ENABLE_METALINK
if (dt.guessMetalinkFile(uri)) {
showMetalinkFile(uri, op);
}
else
#endif // ENABLE_METALINK
# endif // ENABLE_METALINK
{
printf("%s\n\n", MSG_NOT_TORRENT_METALINK);
}

View File

@ -51,7 +51,7 @@
#include "cookie_helper.h"
#include "BufferedFile.h"
#ifdef HAVE_SQLITE3
#include "Sqlite3CookieParserImpl.h"
# include "Sqlite3CookieParserImpl.h"
#endif // HAVE_SQLITE3
namespace aria2 {

View File

@ -37,13 +37,13 @@
#include "common.h"
#ifdef USE_INTERNAL_BIGNUM
#include "InternalDHKeyExchange.h"
# include "InternalDHKeyExchange.h"
#elif HAVE_LIBGMP
#include "LibgmpDHKeyExchange.h"
# include "LibgmpDHKeyExchange.h"
#elif HAVE_LIBGCRYPT
#include "LibgcryptDHKeyExchange.h"
# include "LibgcryptDHKeyExchange.h"
#elif HAVE_OPENSSL
#include "LibsslDHKeyExchange.h"
# include "LibsslDHKeyExchange.h"
#endif // HAVE_OPENSSL
#endif // D_DH_KEY_EXCHANGE_H

View File

@ -51,7 +51,7 @@
#include "fmt.h"
#include "SocketCore.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolverMan.h"
# include "AsyncNameResolverMan.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -57,9 +57,9 @@
#include "BufferedFile.h"
#include "SHA1IOFile.h"
#ifdef ENABLE_BITTORRENT
#include "PeerStorage.h"
#include "BtRuntime.h"
#include "bittorrent_helper.h"
# include "PeerStorage.h"
# include "BtRuntime.h"
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {

View File

@ -70,7 +70,7 @@
#include "RequestGroup.h"
#include "SimpleRandomizer.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {
@ -485,7 +485,7 @@ void DefaultPieceStorage::completePiece(const std::shared_ptr<Piece>& piece)
#ifdef ENABLE_BITTORRENT
if (downloadContext_->hasAttribute(CTX_ATTR_BT)) {
if (!bittorrent::getTorrentAttrs(downloadContext_)->metadata.empty()) {
#ifdef __MINGW32__
# ifdef __MINGW32__
// On Windows, if aria2 opens files with GENERIC_WRITE access
// right, some programs cannot open them aria2 is seeding. To
// avoid this situation, re-open the files with read-only
@ -495,7 +495,7 @@ void DefaultPieceStorage::completePiece(const std::shared_ptr<Piece>& piece)
diskAdaptor_->closeFile();
diskAdaptor_->enableReadOnly();
diskAdaptor_->openFile();
#endif // __MINGW32__
# endif // __MINGW32__
auto group = downloadContext_->getOwnerRequestGroup();
util::executeHookByOptName(group, option_,

View File

@ -68,7 +68,7 @@
#include "MessageDigest.h"
#include "message_digest_helper.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {

View File

@ -68,10 +68,10 @@
#include "fmt.h"
#include "wallclock.h"
#ifdef ENABLE_BITTORRENT
#include "BtRegistry.h"
# include "BtRegistry.h"
#endif // ENABLE_BITTORRENT
#ifdef ENABLE_WEBSOCKET
#include "WebSocketSessionMan.h"
# include "WebSocketSessionMan.h"
#endif // ENABLE_WEBSOCKET
#include "Option.h"
#include "util_security.h"

View File

@ -51,7 +51,7 @@
#include "CheckIntegrityMan.h"
#include "DNSCache.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
# include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -59,19 +59,19 @@
#include "array_fun.h"
#include "EvictSocketPoolCommand.h"
#ifdef HAVE_LIBUV
#include "LibuvEventPoll.h"
# include "LibuvEventPoll.h"
#endif // HAVE_LIBUV
#ifdef HAVE_EPOLL
#include "EpollEventPoll.h"
# include "EpollEventPoll.h"
#endif // HAVE_EPOLL
#ifdef HAVE_PORT_ASSOCIATE
#include "PortEventPoll.h"
# include "PortEventPoll.h"
#endif // HAVE_PORT_ASSOCIATE
#ifdef HAVE_KQUEUE
#include "KqueueEventPoll.h"
# include "KqueueEventPoll.h"
#endif // HAVE_KQUEUE
#ifdef HAVE_POLL
#include "PollEventPoll.h"
# include "PollEventPoll.h"
#endif // HAVE_POLL
#include "SelectEventPoll.h"
#include "DlAbortEx.h"

View File

@ -44,7 +44,7 @@
#include "Event.h"
#include "a2functional.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
# include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -45,7 +45,7 @@
#include "a2netcompat.h"
#include "Command.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
# include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -38,37 +38,37 @@
#include <cstring>
#ifdef HAVE_ZLIB
#include <zlib.h>
# include <zlib.h>
#endif // HAVE_ZLIB
#ifdef HAVE_LIBXML2
#include <libxml/xmlversion.h>
# include <libxml/xmlversion.h>
#endif // HAVE_LIBXML2
#ifdef HAVE_LIBEXPAT
#include <expat.h>
# include <expat.h>
#endif // HAVE_LIBEXPAT
#ifdef HAVE_SQLITE3
#include <sqlite3.h>
# include <sqlite3.h>
#endif // HAVE_SQLITE3
#ifdef HAVE_LIBGNUTLS
#include <gnutls/gnutls.h>
# include <gnutls/gnutls.h>
#endif // HAVE_LIBGNUTLS
#ifdef HAVE_OPENSSL
#include <openssl/opensslv.h>
# include <openssl/opensslv.h>
#endif // HAVE_OPENSSL
#ifdef HAVE_LIBGMP
#include <gmp.h>
# include <gmp.h>
#endif // HAVE_LIBGMP
#ifdef HAVE_LIBGCRYPT
#include <gcrypt.h>
# include <gcrypt.h>
#endif // HAVE_LIBGCRYPT
#ifdef HAVE_LIBCARES
#include <ares.h>
# include <ares.h>
#endif // HAVE_LIBCARES
#ifdef HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
# include <sys/utsname.h>
#endif // HAVE_SYS_UTSNAME_H
#ifdef HAVE_LIBSSH2
#include <libssh2.h>
# include <libssh2.h>
#endif // HAVE_LIBSSH2
#include "util.h"
@ -252,11 +252,11 @@ std::string usedCompilerAndPlatform()
std::stringstream rv;
#if defined(__clang_version__)
#ifdef __apple_build_version__
# ifdef __apple_build_version__
rv << "Apple LLVM ";
#else // !__apple_build_version__
# else // !__apple_build_version__
rv << "clang ";
#endif // !__apple_build_version__
# endif // !__apple_build_version__
rv << __clang_version__;
#elif defined(__INTEL_COMPILER)
@ -266,23 +266,23 @@ std::string usedCompilerAndPlatform()
#elif defined(__MINGW64_VERSION_STR)
rv << "mingw-w64 " << __MINGW64_VERSION_STR;
#ifdef __MINGW64_VERSION_STATE
# ifdef __MINGW64_VERSION_STATE
rv << " (" << __MINGW64_VERSION_STATE << ")";
#endif // __MINGW64_VERSION_STATE
# endif // __MINGW64_VERSION_STATE
rv << " / gcc " << __VERSION__;
#elif defined(__GNUG__)
#ifdef __MINGW32__
# ifdef __MINGW32__
rv << "mingw ";
#ifdef __MINGW32_MAJOR_VERSION
# ifdef __MINGW32_MAJOR_VERSION
rv << (int)__MINGW32_MAJOR_VERSION;
#endif // __MINGW32_MAJOR_VERSION
#ifdef __MINGW32_MINOR_VERSION
# endif // __MINGW32_MAJOR_VERSION
# ifdef __MINGW32_MINOR_VERSION
rv << "." << (int)__MINGW32_MINOR_VERSION;
#endif // __MINGW32_MINOR_VERSION
# endif // __MINGW32_MINOR_VERSION
rv << " / ";
#endif // __MINGW32__
# endif // __MINGW32__
rv << "gcc " << __VERSION__;
#else // !defined(__GNUG__)
@ -348,13 +348,13 @@ std::string getOperatingSystemInfo()
if (ovi.szCSDVersion[0]) {
rv << " (" << ovi.szCSDVersion << ")";
}
#ifdef _WIN64
# ifdef _WIN64
rv << " (x86_64)";
#endif // _WIN64
# endif // _WIN64
rv << " (" << ovi.dwMajorVersion << "." << ovi.dwMinorVersion << ")";
return rv.str();
#else //! _WIN32
#ifdef HAVE_SYS_UTSNAME_H
# ifdef HAVE_SYS_UTSNAME_H
struct utsname name;
if (!uname(&name)) {
if (!strstr(name.version, name.sysname) ||
@ -367,9 +367,9 @@ std::string getOperatingSystemInfo()
}
return name.version;
}
#endif // HAVE_SYS_UTSNAME_H
# endif // HAVE_SYS_UTSNAME_H
return "Unknown system";
#endif // !_WIN32
#endif // !_WIN32
}
} // namespace aria2

View File

@ -37,7 +37,7 @@
#include <stdlib.h>
#include <sys/types.h>
#ifdef HAVE_UTIME_H
#include <utime.h>
# include <utime.h>
#endif // HAVE_UTIME_H
#include <unistd.h>

View File

@ -369,16 +369,16 @@ int FtpConnection::receiveResponse()
}
#ifdef __MINGW32__
#define LONGLONG_PRINTF "%I64d"
#define ULONGLONG_PRINTF "%I64u"
#define LONGLONG_SCANF "%I64d"
#define ULONGLONG_SCANF "%I64u"
# define LONGLONG_PRINTF "%I64d"
# define ULONGLONG_PRINTF "%I64u"
# define LONGLONG_SCANF "%I64d"
# define ULONGLONG_SCANF "%I64u"
#else
#define LONGLONG_PRINTF "%" PRId64 ""
#define ULONGLONG_PRINTF "%llu"
#define LONGLONG_SCANF "%Ld"
# define LONGLONG_PRINTF "%" PRId64 ""
# define ULONGLONG_PRINTF "%llu"
# define LONGLONG_SCANF "%Ld"
// Mac OSX uses "%llu" for 64bits integer.
#define ULONGLONG_SCANF "%Lu"
# define ULONGLONG_SCANF "%Lu"
#endif // __MINGW32__
int FtpConnection::receiveSizeResponse(int64_t& size)

View File

@ -61,8 +61,8 @@
#include "FtpTunnelRequestConnectChain.h"
#include "HttpRequestConnectChain.h"
#ifdef HAVE_LIBSSH2
#include "SftpNegotiationConnectChain.h"
#include "SftpNegotiationCommand.h"
# include "SftpNegotiationConnectChain.h"
# include "SftpNegotiationCommand.h"
#endif // HAVE_LIBSSH2
namespace aria2 {

View File

@ -41,7 +41,7 @@
#include "SocketCore.h"
#include "SocketRecvBuffer.h"
#ifdef HAVE_LIBSSH2
#include "SftpNegotiationCommand.h"
# include "SftpNegotiationCommand.h"
#endif // HAVE_LIBSSH2
namespace aria2 {

View File

@ -61,7 +61,7 @@
#include "array_fun.h"
#include "MessageDigest.h"
#ifdef HAVE_ZLIB
#include "GZipDecodingStreamFilter.h"
# include "GZipDecodingStreamFilter.h"
#endif // HAVE_ZLIB
namespace aria2 {

View File

@ -78,7 +78,7 @@
#include "Checksum.h"
#include "ChecksumCheckIntegrityEntry.h"
#ifdef HAVE_ZLIB
#include "GZipDecodingStreamFilter.h"
# include "GZipDecodingStreamFilter.h"
#endif // HAVE_ZLIB
namespace aria2 {

View File

@ -53,7 +53,7 @@
#include "array_fun.h"
#include "JsonDiskWriter.h"
#ifdef ENABLE_XML_RPC
#include "XmlRpcDiskWriter.h"
# include "XmlRpcDiskWriter.h"
#endif // ENABLE_XML_RPC
namespace aria2 {

View File

@ -61,8 +61,8 @@
#include "JsonDiskWriter.h"
#include "ValueBaseJsonParser.h"
#ifdef ENABLE_XML_RPC
#include "XmlRpcRequestParserStateMachine.h"
#include "XmlRpcDiskWriter.h"
# include "XmlRpcRequestParserStateMachine.h"
# include "XmlRpcDiskWriter.h"
#endif // ENABLE_XML_RPC
namespace aria2 {

View File

@ -54,7 +54,7 @@
#include "MessageDigest.h"
#include "message_digest_helper.h"
#ifdef ENABLE_WEBSOCKET
#include "WebSocketResponseCommand.h"
# include "WebSocketResponseCommand.h"
#endif // ENABLE_WEBSOCKET
namespace aria2 {

View File

@ -46,9 +46,9 @@
#include "fmt.h"
#ifdef KEVENT_UDATA_INTPTR_T
#define PTR_TO_UDATA(X) (reinterpret_cast<intptr_t>(X))
# define PTR_TO_UDATA(X) (reinterpret_cast<intptr_t>(X))
#else // !KEVENT_UDATA_INTPTR_T
#define PTR_TO_UDATA(X) (X)
# define PTR_TO_UDATA(X) (X)
#endif // !KEVENT_UDATA_INTPTR_T
namespace aria2 {

View File

@ -46,7 +46,7 @@
#include "Event.h"
#include "a2functional.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
# include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -37,8 +37,8 @@
#include <sstream>
#ifdef HAVE_LIBGNUTLS
#include <gnutls/x509.h>
#include <gnutls/pkcs12.h>
# include <gnutls/x509.h>
# include <gnutls/pkcs12.h>
#endif // HAVE_LIBGNUTLS
#include "LogFactory.h"

View File

@ -91,7 +91,7 @@ GnuTLSSession::~GnuTLSSession()
#if (GNUTLS_VERSION_NUMBER >= 0x030103 && \
GNUTLS_VERSION_NUMBER <= 0x030112) || \
(GNUTLS_VERSION_NUMBER >= 0x030200 && GNUTLS_VERSION_NUMBER <= 0x030208)
#define A2_DISABLE_OCSP 1
# define A2_DISABLE_OCSP 1
#endif
int GnuTLSSession::init(sock_t sockfd)
@ -99,11 +99,11 @@ int GnuTLSSession::init(sock_t sockfd)
#if GNUTLS_VERSION_NUMBER >= 0x030000
unsigned int flags =
tlsContext_->getSide() == TLS_CLIENT ? GNUTLS_CLIENT : GNUTLS_SERVER;
#ifdef A2_DISABLE_OCSP
# ifdef A2_DISABLE_OCSP
if (tlsContext_->getSide() == TLS_CLIENT) {
flags |= GNUTLS_NO_EXTENSIONS;
}
#endif // A2_DISABLE_OCSP
# endif // A2_DISABLE_OCSP
rv_ = gnutls_init(&sslSession_, flags);
#else // GNUTLS_VERSION_NUMBER >= 0x030000

View File

@ -146,7 +146,7 @@ OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side, TLSVersion minVer)
}
#if OPENSSL_VERSION_NUMBER >= 0x0090800fL
#ifndef OPENSSL_NO_ECDH
# ifndef OPENSSL_NO_ECDH
auto ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
if (ecdh == nullptr) {
A2_LOG_WARN(fmt("Failed to enable ECDHE cipher suites. Cause: %s",
@ -156,8 +156,8 @@ OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side, TLSVersion minVer)
SSL_CTX_set_tmp_ecdh(sslCtx_, ecdh);
EC_KEY_free(ecdh);
}
#endif // OPENSSL_NO_ECDH
#endif // OPENSSL_VERSION_NUMBER >= 0x0090800fL
# endif // OPENSSL_NO_ECDH
#endif // OPENSSL_VERSION_NUMBER >= 0x0090800fL
}
OpenSSLTLSContext::~OpenSSLTLSContext() { SSL_CTX_free(sslCtx_); }

View File

@ -35,10 +35,10 @@
/* copyright --> */
#ifdef __MINGW32__
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif // _WIN32_WINNT
#define _WIN32_WINNT 0x0600
# ifdef _WIN32_WINNT
# undef _WIN32_WINNT
# endif // _WIN32_WINNT
# define _WIN32_WINNT 0x0600
#endif // __MINGW32__
#include "LibuvEventPoll.h"

View File

@ -46,7 +46,7 @@
#include "a2functional.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
# include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -36,9 +36,9 @@
#define D_LOCK_H
#if defined(_WIN32)
#include <windows.h>
# include <windows.h>
#elif defined(ENABLE_PTHREAD)
#include <pthread.h>
# include <pthread.h>
#endif
namespace aria2 {

View File

@ -38,7 +38,7 @@
#include "RecoverableException.h"
#ifdef HAVE_LIBGNUTLS
#include <gnutls/gnutls.h>
# include <gnutls/gnutls.h>
#endif // HAVE_LIBGNUTLS
namespace aria2 {

View File

@ -61,8 +61,8 @@
#include "download_handlers.h"
#include "RequestGroupCriteria.h"
#ifdef ENABLE_BITTORRENT
#include "BtDependency.h"
#include "download_helper.h"
# include "BtDependency.h"
# include "download_helper.h"
#endif // ENABLE_BITTORRENT
#include "Checksum.h"
#include "ChunkChecksum.h"

View File

@ -50,7 +50,7 @@
#include "ChunkChecksum.h"
#include "MessageDigest.h"
#ifdef ENABLE_BITTORRENT
#include "magnet.h"
# include "magnet.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {

View File

@ -38,7 +38,7 @@
#include "AdaptiveFileAllocationIterator.h"
#include "TruncFileAllocationIterator.h"
#ifdef HAVE_SOME_FALLOCATE
#include "FallocFileAllocationIterator.h"
# include "FallocFileAllocationIterator.h"
#endif // HAVE_SOME_FALLOCATE
#include "DiskWriter.h"
#include "DefaultDiskWriterFactory.h"

View File

@ -66,15 +66,15 @@
#include "Notifier.h"
#include "console.h"
#ifdef ENABLE_WEBSOCKET
#include "WebSocketSessionMan.h"
# include "WebSocketSessionMan.h"
#else // !ENABLE_WEBSOCKET
#include "NullWebSocketSessionMan.h"
# include "NullWebSocketSessionMan.h"
#endif // !ENABLE_WEBSOCKET
#ifdef ENABLE_SSL
#include "TLSContext.h"
# include "TLSContext.h"
#endif // ENABLE_SSL
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
# include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {
@ -389,10 +389,10 @@ void MultiUrlRequestInfo::setupSignalHandlers()
#ifdef HAVE_SIGACTION
sigaddset(&mask_, SIGINT);
sigaddset(&mask_, SIGTERM);
#ifdef SIGHUP
# ifdef SIGHUP
sigaddset(&mask_, SIGHUP);
#endif // SIGHUP
#endif // HAVE_SIGACTION
# endif // SIGHUP
#endif // HAVE_SIGACTION
#ifdef SIGHUP
util::setGlobalSignalHandler(SIGHUP, &mask_, handler, 0);

View File

@ -47,7 +47,7 @@
#include "UDPTrackerClient.h"
#include "BtRegistry.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolverMan.h"
# include "AsyncNameResolverMan.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -87,11 +87,11 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
#ifdef ENABLE_ASYNC_DNS
{
OptionHandler* op(new BooleanOptionHandler(PREF_ASYNC_DNS, TEXT_ASYNC_DNS,
#if defined(__ANDROID__) || defined(ANDROID)
# if defined(__ANDROID__) || defined(ANDROID)
A2_V_FALSE,
#else // !__ANDROID__ && !ANDROID
# else // !__ANDROID__ && !ANDROID
A2_V_TRUE,
#endif // !__ANDROID__ && !ANDROID
# endif // !__ANDROID__ && !ANDROID
OptionHandler::OPT_ARG));
op->addTag(TAG_ADVANCED);
op->setInitialOption(true);
@ -99,15 +99,15 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
#if defined(HAVE_ARES_SET_SERVERS) && defined(HAVE_ARES_ADDR_NODE)
# if defined(HAVE_ARES_SET_SERVERS) && defined(HAVE_ARES_ADDR_NODE)
{
OptionHandler* op(new DefaultOptionHandler(
PREF_ASYNC_DNS_SERVER, TEXT_ASYNC_DNS_SERVER, NO_DEFAULT_VALUE));
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
#endif // HAVE_ARES_SET_SERVERS && HAVE_ARES_ADDR_NODE
#endif // ENABLE_ASYNC_DNS
# endif // HAVE_ARES_SET_SERVERS && HAVE_ARES_ADDR_NODE
#endif // ENABLE_ASYNC_DNS
{
OptionHandler* op(new BooleanOptionHandler(
PREF_AUTO_FILE_RENAMING, TEXT_AUTO_FILE_RENAMING, A2_V_TRUE,

View File

@ -42,22 +42,22 @@
#include <iostream>
#ifdef HAVE_OPENSSL
#include <openssl/err.h>
#include <openssl/ssl.h>
# include <openssl/err.h>
# include <openssl/ssl.h>
#endif // HAVE_OPENSSL
#ifdef HAVE_LIBGCRYPT
#include <gcrypt.h>
# include <gcrypt.h>
#endif // HAVE_LIBGCRYPT
#ifdef HAVE_LIBGNUTLS
#include <gnutls/gnutls.h>
# include <gnutls/gnutls.h>
#endif // HAVE_LIBGNUTLS
#ifdef ENABLE_ASYNC_DNS
#include <ares.h>
# include <ares.h>
#endif // ENABLE_ASYNC_DNS
#ifdef HAVE_LIBSSH2
#include <libssh2.h>
# include <libssh2.h>
#endif // HAVE_LIBSSH2
#include "a2netcompat.h"
@ -68,7 +68,7 @@
#include "OptionParser.h"
#include "prefs.h"
#ifdef HAVE_LIBGMP
#include "a2gmp.h"
# include "a2gmp.h"
#endif // HAVE_LIBGMP
#include "LogFactory.h"
#include "util.h"

View File

@ -44,7 +44,7 @@
#include "Event.h"
#include "a2functional.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
# include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -38,7 +38,7 @@
#include "EventPoll.h"
#ifdef HAVE_PORT_H
#include <port.h>
# include <port.h>
#endif // HAVE_PORT_H
#include <set>
@ -46,7 +46,7 @@
#include "Event.h"
#include "a2functional.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
# include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -44,7 +44,7 @@
#include "uri.h"
#include "BufferedFile.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {

View File

@ -82,39 +82,39 @@
#include "CheckIntegrityCommand.h"
#include "ChecksumCheckIntegrityEntry.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
#include "BtRegistry.h"
#include "BtCheckIntegrityEntry.h"
#include "DefaultPeerStorage.h"
#include "DefaultBtAnnounce.h"
#include "BtRuntime.h"
#include "BtSetup.h"
#include "BtPostDownloadHandler.h"
#include "DHTSetup.h"
#include "DHTRegistry.h"
#include "DHTNode.h"
#include "DHTRoutingTable.h"
#include "DHTTaskQueue.h"
#include "DHTTaskFactory.h"
#include "DHTTokenTracker.h"
#include "DHTMessageDispatcher.h"
#include "DHTMessageReceiver.h"
#include "DHTMessageFactory.h"
#include "DHTMessageCallback.h"
#include "BtMessageFactory.h"
#include "BtRequestFactory.h"
#include "BtMessageDispatcher.h"
#include "BtMessageReceiver.h"
#include "PeerConnection.h"
#include "ExtensionMessageFactory.h"
#include "DHTPeerAnnounceStorage.h"
#include "DHTEntryPointNameResolveCommand.h"
#include "LongestSequencePieceSelector.h"
#include "PriorityPieceSelector.h"
#include "bittorrent_helper.h"
# include "bittorrent_helper.h"
# include "BtRegistry.h"
# include "BtCheckIntegrityEntry.h"
# include "DefaultPeerStorage.h"
# include "DefaultBtAnnounce.h"
# include "BtRuntime.h"
# include "BtSetup.h"
# include "BtPostDownloadHandler.h"
# include "DHTSetup.h"
# include "DHTRegistry.h"
# include "DHTNode.h"
# include "DHTRoutingTable.h"
# include "DHTTaskQueue.h"
# include "DHTTaskFactory.h"
# include "DHTTokenTracker.h"
# include "DHTMessageDispatcher.h"
# include "DHTMessageReceiver.h"
# include "DHTMessageFactory.h"
# include "DHTMessageCallback.h"
# include "BtMessageFactory.h"
# include "BtRequestFactory.h"
# include "BtMessageDispatcher.h"
# include "BtMessageReceiver.h"
# include "PeerConnection.h"
# include "ExtensionMessageFactory.h"
# include "DHTPeerAnnounceStorage.h"
# include "DHTEntryPointNameResolveCommand.h"
# include "LongestSequencePieceSelector.h"
# include "PriorityPieceSelector.h"
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
#ifdef ENABLE_METALINK
#include "MetalinkPostDownloadHandler.h"
# include "MetalinkPostDownloadHandler.h"
#endif // ENABLE_METALINK
namespace aria2 {

View File

@ -86,7 +86,7 @@
#include "wallclock.h"
#include "RpcMethodImpl.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {

View File

@ -70,12 +70,12 @@
#include "message_digest_helper.h"
#include "OpenedFileCounter.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
#include "BtRegistry.h"
#include "PeerStorage.h"
#include "Peer.h"
#include "BtRuntime.h"
#include "BtAnnounce.h"
# include "bittorrent_helper.h"
# include "BtRegistry.h"
# include "PeerStorage.h"
# include "Peer.h"
# include "BtRuntime.h"
# include "BtAnnounce.h"
#endif // ENABLE_BITTORRENT
#include "CheckIntegrityEntry.h"

View File

@ -40,7 +40,7 @@
#include "util.h"
#include "json.h"
#ifdef HAVE_ZLIB
#include "GZipEncoder.h"
# include "GZipEncoder.h"
#endif // HAVE_ZLIB
namespace aria2 {

View File

@ -35,7 +35,7 @@
#include "SelectEventPoll.h"
#ifdef __MINGW32__
#include <cassert>
# include <cassert>
#endif // __MINGW32__
#include <cstring>
#include <algorithm>

View File

@ -42,7 +42,7 @@
#include "a2functional.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
# include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
namespace aria2 {

View File

@ -56,7 +56,7 @@
#include "SHA1IOFile.h"
#if HAVE_ZLIB
#include "GZipFile.h"
# include "GZipFile.h"
#endif
namespace aria2 {

View File

@ -46,9 +46,9 @@
#include "fmt.h"
#ifdef HAVE_GETRANDOM_INTERFACE
#include <errno.h>
#include <linux/errno.h>
#include "getrandom_linux.h"
# include <errno.h>
# include <linux/errno.h>
# include "getrandom_linux.h"
#endif
namespace aria2 {
@ -97,7 +97,7 @@ void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len)
BOOL r = CryptGenRandom(provider_, len, reinterpret_cast<BYTE*>(buf));
assert(r);
#else // ! __MINGW32__
#if defined(HAVE_GETRANDOM_INTERFACE)
# if defined(HAVE_GETRANDOM_INTERFACE)
static bool have_random_support = true;
if (have_random_support) {
auto rv = getrandom_linux(buf, len);
@ -111,7 +111,7 @@ void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len)
"implement this feature (ENOSYS)");
}
// Fall through to generic implementation
#endif // defined(HAVE_GETRANDOM_INTERFACE)
# endif // defined(HAVE_GETRANDOM_INTERFACE)
auto ubuf = reinterpret_cast<result_type*>(buf);
size_t q = len / sizeof(result_type);
auto dis = std::uniform_int_distribution<result_type>();
@ -121,7 +121,7 @@ void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len)
const size_t r = len % sizeof(result_type);
auto last = dis(gen_);
memcpy(ubuf, &last, r);
#endif // ! __MINGW32__
#endif // ! __MINGW32__
}
} // namespace aria2

View File

@ -41,7 +41,7 @@
#include <random>
#ifdef __MINGW32__
#include <wincrypt.h>
# include <wincrypt.h>
#endif
namespace aria2 {

View File

@ -35,12 +35,12 @@
#include "SocketCore.h"
#ifdef HAVE_IPHLPAPI_H
#include <iphlpapi.h>
# include <iphlpapi.h>
#endif // HAVE_IPHLPAPI_H
#include <unistd.h>
#ifdef HAVE_IFADDRS_H
#include <ifaddrs.h>
# include <ifaddrs.h>
#endif // HAVE_IFADDRS_H
#include <cerrno>
@ -59,44 +59,44 @@
#include "LogFactory.h"
#include "A2STR.h"
#ifdef ENABLE_SSL
#include "TLSContext.h"
#include "TLSSession.h"
# include "TLSContext.h"
# include "TLSSession.h"
#endif // ENABLE_SSL
#ifdef HAVE_LIBSSH2
#include "SSHSession.h"
# include "SSHSession.h"
#endif // HAVE_LIBSSH2
namespace aria2 {
#ifndef __MINGW32__
#define SOCKET_ERRNO (errno)
# define SOCKET_ERRNO (errno)
#else
#define SOCKET_ERRNO (WSAGetLastError())
# define SOCKET_ERRNO (WSAGetLastError())
#endif // __MINGW32__
#ifdef __MINGW32__
#define A2_EINPROGRESS WSAEWOULDBLOCK
#define A2_EWOULDBLOCK WSAEWOULDBLOCK
#define A2_EINTR WSAEINTR
#define A2_WOULDBLOCK(e) (e == WSAEWOULDBLOCK)
# define A2_EINPROGRESS WSAEWOULDBLOCK
# define A2_EWOULDBLOCK WSAEWOULDBLOCK
# define A2_EINTR WSAEINTR
# define A2_WOULDBLOCK(e) (e == WSAEWOULDBLOCK)
#else // !__MINGW32__
#define A2_EINPROGRESS EINPROGRESS
#ifndef EWOULDBLOCK
#define EWOULDBLOCK EAGAIN
#endif // EWOULDBLOCK
#define A2_EWOULDBLOCK EWOULDBLOCK
#define A2_EINTR EINTR
#if EWOULDBLOCK == EAGAIN
#define A2_WOULDBLOCK(e) (e == EWOULDBLOCK)
#else // EWOULDBLOCK != EAGAIN
#define A2_WOULDBLOCK(e) (e == EWOULDBLOCK || e == EAGAIN)
#endif // EWOULDBLOCK != EAGAIN
#endif // !__MINGW32__
# define A2_EINPROGRESS EINPROGRESS
# ifndef EWOULDBLOCK
# define EWOULDBLOCK EAGAIN
# endif // EWOULDBLOCK
# define A2_EWOULDBLOCK EWOULDBLOCK
# define A2_EINTR EINTR
# if EWOULDBLOCK == EAGAIN
# define A2_WOULDBLOCK(e) (e == EWOULDBLOCK)
# else // EWOULDBLOCK != EAGAIN
# define A2_WOULDBLOCK(e) (e == EWOULDBLOCK || e == EAGAIN)
# endif // EWOULDBLOCK != EAGAIN
#endif // !__MINGW32__
#ifdef __MINGW32__
#define CLOSE(X) ::closesocket(X)
# define CLOSE(X) ::closesocket(X)
#else
#define CLOSE(X) close(X)
# define CLOSE(X) close(X)
#endif // __MINGW32__
namespace {
@ -655,12 +655,12 @@ void SocketCore::closeConnection()
}
#ifndef __MINGW32__
#define CHECK_FD(fd) \
if (fd < 0 || FD_SETSIZE <= fd) { \
logger_->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \
"Download may slow down or fail."); \
return false; \
}
# define CHECK_FD(fd) \
if (fd < 0 || FD_SETSIZE <= fd) { \
logger_->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \
"Download may slow down or fail."); \
return false; \
}
#endif // !__MINGW32__
bool SocketCore::isWritable(time_t timeout)
@ -681,9 +681,9 @@ bool SocketCore::isWritable(time_t timeout)
}
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_WRITABLE, errorMsg(errNum).c_str()));
#else // !HAVE_POLL
#ifndef __MINGW32__
# ifndef __MINGW32__
CHECK_FD(sockfd_);
#endif // !__MINGW32__
# endif // !__MINGW32__
fd_set fds;
FD_ZERO(&fds);
FD_SET(sockfd_, &fds);
@ -705,7 +705,7 @@ bool SocketCore::isWritable(time_t timeout)
return false;
}
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_WRITABLE, errorMsg(errNum).c_str()));
#endif // !HAVE_POLL
#endif // !HAVE_POLL
}
bool SocketCore::isReadable(time_t timeout)
@ -726,9 +726,9 @@ bool SocketCore::isReadable(time_t timeout)
}
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_READABLE, errorMsg(errNum).c_str()));
#else // !HAVE_POLL
#ifndef __MINGW32__
# ifndef __MINGW32__
CHECK_FD(sockfd_);
#endif // !__MINGW32__
# endif // !__MINGW32__
fd_set fds;
FD_ZERO(&fds);
FD_SET(sockfd_, &fds);
@ -750,7 +750,7 @@ bool SocketCore::isReadable(time_t timeout)
return false;
}
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_READABLE, errorMsg(errNum).c_str()));
#endif // !HAVE_POLL
#endif // !HAVE_POLL
}
ssize_t SocketCore::writeVector(a2iovec* iov, size_t iovcnt)

View File

@ -43,7 +43,7 @@
#include "A2STR.h"
#include "cookie_helper.h"
#ifndef HAVE_SQLITE3_OPEN_V2
#include "File.h"
# include "File.h"
#endif // !HAVE_SQLITE3_OPEN_V2
namespace aria2 {

View File

@ -46,7 +46,7 @@
#include "OptionParser.h"
#if HAVE_ZLIB
#include "GZipFile.h"
# include "GZipFile.h"
#endif
namespace aria2 {

View File

@ -58,9 +58,9 @@
#include "fmt.h"
#ifdef __APPLE__
#import <sys/types.h>
#import <sys/sysctl.h>
#define MIBSIZE 4
# import <sys/types.h>
# import <sys/sysctl.h>
# define MIBSIZE 4
#endif
namespace aria2 {

View File

@ -45,20 +45,20 @@
#include "util.h"
#ifndef SP_PROT_TLS1_1_CLIENT
#define SP_PROT_TLS1_1_CLIENT 0x00000200
# define SP_PROT_TLS1_1_CLIENT 0x00000200
#endif
#ifndef SP_PROT_TLS1_1_SERVER
#define SP_PROT_TLS1_1_SERVER 0x00000100
# define SP_PROT_TLS1_1_SERVER 0x00000100
#endif
#ifndef SP_PROT_TLS1_2_CLIENT
#define SP_PROT_TLS1_2_CLIENT 0x00000800
# define SP_PROT_TLS1_2_CLIENT 0x00000800
#endif
#ifndef SP_PROT_TLS1_2_SERVER
#define SP_PROT_TLS1_2_SERVER 0x00000400
# define SP_PROT_TLS1_2_SERVER 0x00000400
#endif
#ifndef SCH_USE_STRONG_CRYPTO
#define SCH_USE_STRONG_CRYPTO 0x00400000
# define SCH_USE_STRONG_CRYPTO 0x00400000
#endif
#define WEAK_CIPHER_BITS 56

View File

@ -44,17 +44,17 @@
#include "util.h"
#ifndef SECBUFFER_ALERT
#define SECBUFFER_ALERT 17
# define SECBUFFER_ALERT 17
#endif
#ifndef SZ_ALG_MAX_SIZE
#define SZ_ALG_MAX_SIZE 64
# define SZ_ALG_MAX_SIZE 64
#endif
#ifndef SECPKGCONTEXT_CIPHERINFO_V1
#define SECPKGCONTEXT_CIPHERINFO_V1 1
# define SECPKGCONTEXT_CIPHERINFO_V1 1
#endif
#ifndef SECPKG_ATTR_CIPHER_INFO
#define SECPKG_ATTR_CIPHER_INFO 0x64
# define SECPKG_ATTR_CIPHER_INFO 0x64
#endif
namespace {

View File

@ -61,9 +61,9 @@ struct SessionData {
} // namespace aria2
#ifdef HAVE_LIBXML2
#include "Xml2XmlParser.h"
# include "Xml2XmlParser.h"
#elif HAVE_LIBEXPAT
#include "ExpatXmlParser.h"
# include "ExpatXmlParser.h"
#endif
namespace aria2 {

View File

@ -41,159 +41,159 @@
#include <fcntl.h>
#include <cerrno>
#ifdef HAVE_POLL_H
#include <poll.h>
# include <poll.h>
#endif // HAVE_POLL_H
#ifdef HAVE_IO_H
#include <io.h>
# include <io.h>
#endif // HAVE_IO_H
#ifdef HAVE_WINIOCTL_H
#include <winioctl.h>
# include <winioctl.h>
#endif // HAVE_WINIOCTL_H
#ifdef HAVE_SHARE_H
#include <share.h>
# include <share.h>
#endif // HAVE_SHARE_H
// in some platforms following definitions are missing:
#ifndef EINPROGRESS
#define EINPROGRESS (WSAEINPROGRESS)
# define EINPROGRESS (WSAEINPROGRESS)
#endif // EINPROGRESS
#ifndef O_NONBLOCK
#define O_NONBLOCK (O_NDELAY)
# define O_NONBLOCK (O_NDELAY)
#endif // O_NONBLOCK
#ifndef O_BINARY
#define O_BINARY (0)
# define O_BINARY (0)
#endif // O_BINARY
// st_mode flags
#ifndef S_IRUSR
#define S_IRUSR 0000400 /* read permission, owner */
#endif /* S_IRUSR */
# define S_IRUSR 0000400 /* read permission, owner */
#endif /* S_IRUSR */
#ifndef S_IWUSR
#define S_IWUSR 0000200 /* write permission, owner */
#endif /* S_IWUSR */
# define S_IWUSR 0000200 /* write permission, owner */
#endif /* S_IWUSR */
#ifndef S_IXUSR
#define S_IXUSR 0000100 /* execute/search permission, owner */
#endif /* S_IXUSR */
# define S_IXUSR 0000100 /* execute/search permission, owner */
#endif /* S_IXUSR */
#ifndef S_IRWXU
#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
#endif /* S_IRWXU */
#ifndef S_IRGRP
#define S_IRGRP 0000040 /* read permission, group */
#endif /* S_IRGRP */
# define S_IRGRP 0000040 /* read permission, group */
#endif /* S_IRGRP */
#ifndef S_IWGRP
#define S_IWGRP 0000020 /* write permission, group */
#endif /* S_IWGRP */
# define S_IWGRP 0000020 /* write permission, group */
#endif /* S_IWGRP */
#ifndef S_IXGRP
#define S_IXGRP 0000010 /* execute/search permission, group */
#endif /* S_IXGRP */
# define S_IXGRP 0000010 /* execute/search permission, group */
#endif /* S_IXGRP */
#ifndef S_IRWXG
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
#endif /* S_IRWXG */
#ifndef S_IROTH
#define S_IROTH 0000004 /* read permission, other */
#endif /* S_IROTH */
# define S_IROTH 0000004 /* read permission, other */
#endif /* S_IROTH */
#ifndef S_IWOTH
#define S_IWOTH 0000002 /* write permission, other */
#endif /* S_IWOTH */
# define S_IWOTH 0000002 /* write permission, other */
#endif /* S_IWOTH */
#ifndef S_IXOTH
#define S_IXOTH 0000001 /* execute/search permission, other */
#endif /* S_IXOTH */
# define S_IXOTH 0000001 /* execute/search permission, other */
#endif /* S_IXOTH */
#ifndef S_IRWXO
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
#endif /* S_IRWXO */
// Use 'nul' instead of /dev/null in win32.
#ifdef HAVE_WINSOCK2_H
#define DEV_NULL "nul"
# define DEV_NULL "nul"
#else
#define DEV_NULL "/dev/null"
# define DEV_NULL "/dev/null"
#endif // HAVE_WINSOCK2_H
// Use 'con' instead of '/dev/stdin' and '/dev/stdout' in win32.
#ifdef HAVE_WINSOCK2_H
#define DEV_STDIN "con"
#define DEV_STDOUT "con"
# define DEV_STDIN "con"
# define DEV_STDOUT "con"
#else
#define DEV_STDIN "/dev/stdin"
#define DEV_STDOUT "/dev/stdout"
# define DEV_STDIN "/dev/stdin"
# define DEV_STDOUT "/dev/stdout"
#endif // HAVE_WINSOCK2_H
#ifdef __MINGW32__
#define a2lseek(fd, offset, origin) _lseeki64(fd, offset, origin)
#define a2fseek(fd, offset, origin) _fseeki64(fd, offset, origin)
#define a2fstat(fd, buf) _fstati64(fd, buf)
#define a2ftell(fd) _ftelli64(fd)
#define a2wstat(path, buf) _wstati64(path, buf)
#ifdef stat
#undef stat
#endif // stat
#define a2_struct_stat struct _stati64
#define a2stat(path, buf) _wstati64(path, buf)
#define a2tell(handle) _telli64(handle)
#define a2mkdir(path, openMode) _wmkdir(path)
#define a2utimbuf _utimbuf
#define a2utime(path, times) _wutime(path, times)
#define a2unlink(path) _wunlink(path)
#define a2rmdir(path) _wrmdir(path)
# define a2lseek(fd, offset, origin) _lseeki64(fd, offset, origin)
# define a2fseek(fd, offset, origin) _fseeki64(fd, offset, origin)
# define a2fstat(fd, buf) _fstati64(fd, buf)
# define a2ftell(fd) _ftelli64(fd)
# define a2wstat(path, buf) _wstati64(path, buf)
# ifdef stat
# undef stat
# endif // stat
# define a2_struct_stat struct _stati64
# define a2stat(path, buf) _wstati64(path, buf)
# define a2tell(handle) _telli64(handle)
# define a2mkdir(path, openMode) _wmkdir(path)
# define a2utimbuf _utimbuf
# define a2utime(path, times) _wutime(path, times)
# define a2unlink(path) _wunlink(path)
# define a2rmdir(path) _wrmdir(path)
// For Windows, we share files for reading and writing.
#define a2open(path, flags, mode) _wsopen(path, flags, _SH_DENYNO, mode)
#define a2fopen(path, mode) _wfsopen(path, mode, _SH_DENYNO)
# define a2open(path, flags, mode) _wsopen(path, flags, _SH_DENYNO, mode)
# define a2fopen(path, mode) _wfsopen(path, mode, _SH_DENYNO)
// # define a2ftruncate(fd, length): We don't use ftruncate in Mingw build
#define a2_off_t off_t
# define a2_off_t off_t
#elif defined(__ANDROID__) || defined(ANDROID)
#define a2lseek(fd, offset, origin) lseek64(fd, offset, origin)
# define a2lseek(fd, offset, origin) lseek64(fd, offset, origin)
// # define a2fseek(fp, offset, origin): No fseek64 and not used in aria2
#define a2fstat(fd, buf) fstat64(fd, buf)
# define a2fstat(fd, buf) fstat64(fd, buf)
// # define a2ftell(fd): No ftell64 and not used in aria2
#define a2_struct_stat struct stat
#define a2stat(path, buf) stat64(path, buf)
#define a2mkdir(path, openMode) mkdir(path, openMode)
#define a2utimbuf utimbuf
#define a2utime(path, times) ::utime(path, times)
#define a2unlink(path) unlink(path)
#define a2rmdir(path) rmdir(path)
#define a2open(path, flags, mode) open(path, flags, mode)
#define a2fopen(path, mode) fopen(path, mode)
# define a2_struct_stat struct stat
# define a2stat(path, buf) stat64(path, buf)
# define a2mkdir(path, openMode) mkdir(path, openMode)
# define a2utimbuf utimbuf
# define a2utime(path, times) ::utime(path, times)
# define a2unlink(path) unlink(path)
# define a2rmdir(path) rmdir(path)
# define a2open(path, flags, mode) open(path, flags, mode)
# define a2fopen(path, mode) fopen(path, mode)
// Android NDK R8e does not provide ftruncate64 prototype, so let's
// define it here.
#ifdef __cplusplus
# ifdef __cplusplus
extern "C" {
#endif
# endif
extern int ftruncate64(int fd, off64_t length);
#ifdef __cplusplus
# ifdef __cplusplus
}
#endif
#define a2ftruncate(fd, length) ftruncate64(fd, length)
# endif
# define a2ftruncate(fd, length) ftruncate64(fd, length)
// Use off64_t directly since android does not offer transparent
// switching between off_t and off64_t.
#define a2_off_t off64_t
# define a2_off_t off64_t
#else // !__MINGW32__ && !(defined(__ANDROID__) || defined(ANDROID))
#define a2lseek(fd, offset, origin) lseek(fd, offset, origin)
#define a2fseek(fp, offset, origin) fseek(fp, offset, origin)
#define a2fstat(fp, buf) fstat(fp, buf)
#define a2ftell(fp) ftell(fp)
#define a2_struct_stat struct stat
#define a2stat(path, buf) stat(path, buf)
#define a2mkdir(path, openMode) mkdir(path, openMode)
#define a2utimbuf utimbuf
#define a2utime(path, times) ::utime(path, times)
#define a2unlink(path) unlink(path)
#define a2rmdir(path) rmdir(path)
#define a2open(path, flags, mode) open(path, flags, mode)
#define a2fopen(path, mode) fopen(path, mode)
#define a2ftruncate(fd, length) ftruncate(fd, length)
#define a2_off_t off_t
# define a2lseek(fd, offset, origin) lseek(fd, offset, origin)
# define a2fseek(fp, offset, origin) fseek(fp, offset, origin)
# define a2fstat(fp, buf) fstat(fp, buf)
# define a2ftell(fp) ftell(fp)
# define a2_struct_stat struct stat
# define a2stat(path, buf) stat(path, buf)
# define a2mkdir(path, openMode) mkdir(path, openMode)
# define a2utimbuf utimbuf
# define a2utime(path, times) ::utime(path, times)
# define a2unlink(path) unlink(path)
# define a2rmdir(path) rmdir(path)
# define a2open(path, flags, mode) open(path, flags, mode)
# define a2fopen(path, mode) fopen(path, mode)
# define a2ftruncate(fd, length) ftruncate(fd, length)
# define a2_off_t off_t
#endif
#define OPEN_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
#define DIR_OPEN_MODE S_IRWXU | S_IRWXG | S_IRWXO
#ifdef __MINGW32__
#define A2_BAD_FD INVALID_HANDLE_VALUE
# define A2_BAD_FD INVALID_HANDLE_VALUE
#else // !__MINGW32__
#define A2_BAD_FD -1
# define A2_BAD_FD -1
#endif // !__MINGW32__
#endif // D_A2IO_H

View File

@ -38,78 +38,78 @@
#include "a2io.h"
#ifdef __MINGW32__
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif // HAVE_WS2TCPIP_H
#endif // __MINGW32__
# ifdef HAVE_WS2TCPIP_H
# include <ws2tcpip.h>
# endif // HAVE_WS2TCPIP_H
#endif // __MINGW32__
#ifdef __MINGW32__
#define a2_sockopt_t char*
#ifndef HAVE_GETADDRINFO
#define HAVE_GETADDRINFO
#endif // !HAVE_GETADDRINFO
#undef HAVE_GAI_STRERROR
#undef gai_strerror
# define a2_sockopt_t char*
# ifndef HAVE_GETADDRINFO
# define HAVE_GETADDRINFO
# endif // !HAVE_GETADDRINFO
# undef HAVE_GAI_STRERROR
# undef gai_strerror
#else
#define a2_sockopt_t void*
# define a2_sockopt_t void*
#endif // __MINGW32__
#ifdef HAVE_NETDB_H
#include <netdb.h>
# include <netdb.h>
#endif // HAVE_NETDB_H
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
# include <sys/socket.h>
#endif // HAVE_SYS_SOCKET_H
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
# include <netinet/in.h>
#endif // HAVE_NETINET_IN_H
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
# include <netinet/tcp.h>
#endif // HAVE_NETINET_TCP_H
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
# include <arpa/inet.h>
#endif // HAVE_ARPA_INET_H
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
# include <netinet/in.h>
#endif // HAVE_NETINET_IN_H
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
# include <sys/uio.h>
#endif // HAVE_SYS_UIO_H
#ifndef HAVE_GETADDRINFO
#include "getaddrinfo.h"
#define HAVE_GAI_STRERROR
# include "getaddrinfo.h"
# define HAVE_GAI_STRERROR
#endif // HAVE_GETADDRINFO
#ifndef HAVE_GAI_STRERROR
#include "gai_strerror.h"
# include "gai_strerror.h"
#endif // HAVE_GAI_STRERROR
#include <string>
#ifdef HAVE_WINSOCK2_H
#define sock_t SOCKET
# define sock_t SOCKET
#else
#define sock_t int
# define sock_t int
#endif
#ifndef AI_ADDRCONFIG
#define AI_ADDRCONFIG 0
# define AI_ADDRCONFIG 0
#endif // !AI_ADDRCONFIG
#define DEFAULT_AI_FLAGS AI_ADDRCONFIG
#ifdef __MINGW32__
#ifndef SHUT_WR
#define SHUT_WR SD_SEND
#endif // !SHUT_WR
#endif // __MINGW32__
# ifndef SHUT_WR
# define SHUT_WR SD_SEND
# endif // !SHUT_WR
#endif // __MINGW32__
union sockaddr_union {
sockaddr sa;
@ -136,19 +136,19 @@ struct Endpoint {
#define A2_DEFAULT_IOV_MAX 128
#if defined(IOV_MAX) && IOV_MAX < A2_DEFAULT_IOV_MAX
#define A2_IOV_MAX IOV_MAX
# define A2_IOV_MAX IOV_MAX
#else
#define A2_IOV_MAX A2_DEFAULT_IOV_MAX
# define A2_IOV_MAX A2_DEFAULT_IOV_MAX
#endif
#ifdef __MINGW32__
typedef WSABUF a2iovec;
#define A2IOVEC_BASE buf
#define A2IOVEC_LEN len
# define A2IOVEC_BASE buf
# define A2IOVEC_LEN len
#else // !__MINGW32__
typedef struct iovec a2iovec;
#define A2IOVEC_BASE iov_base
#define A2IOVEC_LEN iov_len
# define A2IOVEC_BASE iov_base
# define A2IOVEC_LEN iov_len
#endif // !__MINGW32__
#endif // D_A2NETCOMPAT_H

View File

@ -41,31 +41,31 @@
#include <chrono>
#ifndef HAVE_LOCALTIME_R
#include "localtime_r.h"
# include "localtime_r.h"
#endif // HAVE_LOCALTIME_R
#ifndef HAVE_GETTIMEOFDAY
#include "gettimeofday.h"
# include "gettimeofday.h"
#endif // HAVE_GETTIMEOFDAY
#ifndef HAVE_STRPTIME
#include "strptime.h"
# include "strptime.h"
#endif // HAVE_STRPTIME
#ifndef HAVE_TIMEGM
#include "timegm.h"
# include "timegm.h"
#endif // HAVE_TIMEGM
#ifndef HAVE_ASCTIME_R
#include "asctime_r.h"
# include "asctime_r.h"
#endif // HAVE_ASCTIME_R
#ifdef __MINGW32__
#define suseconds_t uint64_t
# define suseconds_t uint64_t
#endif
#ifndef HAVE_A2_STRUCT_TIMESPEC
#include "timespec.h"
# include "timespec.h"
#endif // !HAVE_A2_STRUCT_TIMESPEC
// Rounding error in millis

View File

@ -22,18 +22,18 @@
your main control loop, etc. to force garbage collection. */
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#if HAVE_STRING_H
#include <string.h>
# include <string.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
# include <stdlib.h>
#endif
#ifdef emacs
#include "blockinput.h"
# include "blockinput.h"
#endif
/* If compiling with GCC 2, this file's not needed. */
@ -41,40 +41,40 @@
/* If someone has defined alloca as a macro,
there must be some other way alloca is supposed to work. */
#ifndef alloca
# ifndef alloca
#ifdef emacs
#ifdef static
# ifdef emacs
# ifdef static
/* actually, only want this if static is defined as ""
-- this is for usg, in which emacs must undefine static
in order to make unexec workable
*/
#ifndef STACK_DIRECTION
# ifndef STACK_DIRECTION
you lose-- must know STACK_DIRECTION at compile - time
#endif /* STACK_DIRECTION undefined */
#endif /* static */
#endif /* emacs */
# endif /* STACK_DIRECTION undefined */
# endif /* static */
# endif /* emacs */
/* If your stack is a linked list of frames, you have to
provide an "address metric" ADDRESS_FUNCTION macro. */
#if defined(CRAY) && defined(CRAY_STACKSEG_END)
# if defined(CRAY) && defined(CRAY_STACKSEG_END)
long
i00afunc();
#define ADDRESS_FUNCTION(arg) (char*)i00afunc(&(arg))
#else
#define ADDRESS_FUNCTION(arg) &(arg)
#endif
# define ADDRESS_FUNCTION(arg) (char*)i00afunc(&(arg))
# else
# define ADDRESS_FUNCTION(arg) &(arg)
# endif
#if __STDC__
# if __STDC__
typedef void* pointer;
#else
# else
typedef char* pointer;
#endif
# endif
#ifndef NULL
#define NULL 0
#endif
# ifndef NULL
# define NULL 0
# endif
/* Different portions of Emacs need to call different versions of
malloc. The Emacs executable needs alloca to call xmalloc, because
@ -86,10 +86,10 @@ typedef char* pointer;
Callers below should use malloc. */
#ifndef emacs
#undef malloc
#define malloc xmalloc
#endif
# ifndef emacs
# undef malloc
# define malloc xmalloc
# endif
extern pointer malloc();
/* Define STACK_DIRECTION if you know the direction of stack
@ -100,18 +100,18 @@ extern pointer malloc();
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#ifndef STACK_DIRECTION
#define STACK_DIRECTION 0 /* Direction unknown. */
#endif
# ifndef STACK_DIRECTION
# define STACK_DIRECTION 0 /* Direction unknown. */
# endif
#if STACK_DIRECTION != 0
# if STACK_DIRECTION != 0
#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
#else /* STACK_DIRECTION == 0; need run-time code. */
# else /* STACK_DIRECTION == 0; need run-time code. */
static int stack_dir; /* 1 or -1 once known. */
#define STACK_DIR stack_dir
# define STACK_DIR stack_dir
static void find_stack_direction()
{
@ -132,7 +132,7 @@ static void find_stack_direction()
}
}
#endif /* STACK_DIRECTION == 0 */
# endif /* STACK_DIRECTION == 0 */
/* An "alloca header" is used to:
(a) chain together all alloca'ed blocks;
@ -141,9 +141,9 @@ static void find_stack_direction()
It is very important that sizeof(header) agree with malloc
alignment chunk size. The following default should work okay. */
#ifndef ALIGN_SIZE
#define ALIGN_SIZE sizeof(double)
#endif
# ifndef ALIGN_SIZE
# define ALIGN_SIZE sizeof(double)
# endif
typedef union hdr {
char align[ALIGN_SIZE]; /* To force sizeof(header). */
@ -167,10 +167,10 @@ pointer alloca(size_t size)
auto char probe; /* Probes stack depth: */
register char* depth = ADDRESS_FUNCTION(probe);
#if STACK_DIRECTION == 0
# if STACK_DIRECTION == 0
if (STACK_DIR == 0) /* Unknown growth direction. */
find_stack_direction();
#endif
# endif
/* Reclaim garbage, defined as all alloca'd storage that
was allocated from deeper in the stack than currently. */
@ -178,9 +178,9 @@ pointer alloca(size_t size)
{
register header* hp; /* Traverses linked list. */
#ifdef emacs
# ifdef emacs
BLOCK_INPUT;
#endif
# endif
for (hp = last_alloca_header; hp != NULL;)
if ((STACK_DIR > 0 && hp->h.deep > depth) ||
@ -196,9 +196,9 @@ pointer alloca(size_t size)
last_alloca_header = hp; /* -> last valid storage. */
#ifdef emacs
# ifdef emacs
UNBLOCK_INPUT;
#endif
# endif
}
if (size == 0)
@ -224,15 +224,15 @@ pointer alloca(size_t size)
}
}
#if defined(CRAY) && defined(CRAY_STACKSEG_END)
# if defined(CRAY) && defined(CRAY_STACKSEG_END)
#ifdef DEBUG_I00AFUNC
#include <stdio.h>
#endif
# ifdef DEBUG_I00AFUNC
# include <stdio.h>
# endif
#ifndef CRAY_STACK
#define CRAY_STACK
#ifndef CRAY2
# ifndef CRAY_STACK
# define CRAY_STACK
# ifndef CRAY2
/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
struct stack_control_header {
long shgrow : 32; /* Number of times stack has grown. */
@ -282,7 +282,7 @@ struct stack_segment_linkage {
long sss7;
};
#else /* CRAY2 */
# else /* CRAY2 */
/* The following structure defines the vector of words
returned by the STKSTAT library routine. */
struct stk_stat {
@ -333,10 +333,10 @@ struct stk_trailer {
long unknown14;
};
#endif /* CRAY2 */
#endif /* not CRAY_STACK */
# endif /* CRAY2 */
# endif /* not CRAY_STACK */
#ifdef CRAY2
# ifdef CRAY2
/* Determine a "stack measure" for an arbitrary ADDRESS.
I doubt that "lint" will like this much. */
@ -401,7 +401,7 @@ static long i00afunc(long* address)
return (result);
}
#else /* not CRAY2 */
# else /* not CRAY2 */
/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
Determine the number of the cell within the stack,
given the address of the cell. The purpose of this
@ -444,9 +444,9 @@ static long i00afunc(long address)
contain the target address. */
while (!(this_segment <= address && address <= stkl)) {
#ifdef DEBUG_I00AFUNC
# ifdef DEBUG_I00AFUNC
fprintf(stderr, "%011o %011o %011o\n", this_segment, address, stkl);
#endif
# endif
if (pseg == 0)
break;
stkl = stkl - pseg;
@ -464,9 +464,9 @@ static long i00afunc(long address)
a cycle somewhere. */
while (pseg != 0) {
#ifdef DEBUG_I00AFUNC
# ifdef DEBUG_I00AFUNC
fprintf(stderr, "%011o %011o\n", pseg, size);
#endif
# endif
stkl = stkl - pseg;
ssptr = (struct stack_segment_linkage*)stkl;
size = ssptr->sssize;
@ -476,8 +476,8 @@ static long i00afunc(long address)
return (result);
}
#endif /* not CRAY2 */
#endif /* CRAY */
# endif /* not CRAY2 */
# endif /* CRAY */
#endif /* no alloca */
#endif /* not GCC version 2 */
# endif /* no alloca */
#endif /* not GCC version 2 */

View File

@ -63,7 +63,7 @@
#include "Notifier.h"
#include "ApiCallbackDownloadEventListener.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {

View File

@ -37,8 +37,8 @@
#include <stdlib.h>
#ifdef __MINGW32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif // __MINGW32__
#include "asctime_r.h"

View File

@ -36,34 +36,34 @@
#define D_COMMON_H
#ifdef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif
#ifdef __MINGW32__
#ifdef malloc
#undef malloc
#endif
#ifdef realloc
#undef realloc
#endif
# ifdef malloc
# undef malloc
# endif
# ifdef realloc
# undef realloc
# endif
#endif // __MINGW32__
#ifdef __MINGW32__
#define WIN32_LEAN_AND_MEAN
#ifndef WINVER
#define WINVER 0x501
#endif // !WINVER
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x501
#endif // _WIN32_WINNT
#ifdef HAVE_WINSOCK2_H
#ifndef FD_SETSIZE
#define FD_SETSIZE 32768
#endif // !FD_SETSIZE
#include <winsock2.h>
#undef ERROR
#endif // HAVE_WINSOCK2_H
#include <windows.h>
# define WIN32_LEAN_AND_MEAN
# ifndef WINVER
# define WINVER 0x501
# endif // !WINVER
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x501
# endif // _WIN32_WINNT
# ifdef HAVE_WINSOCK2_H
# ifndef FD_SETSIZE
# define FD_SETSIZE 32768
# endif // !FD_SETSIZE
# include <winsock2.h>
# undef ERROR
# endif // HAVE_WINSOCK2_H
# include <windows.h>
#endif // __MINGW32__
#ifdef ENABLE_NLS
@ -75,27 +75,27 @@
// it is defined as non-function form, this causes compile error. User
// reported gcc-4.2.2 has this problem. But gcc-4.4.5 does not suffer
// from this problem.
#include <gettext.h>
#define _(String) gettext(String)
# include <gettext.h>
# define _(String) gettext(String)
#else // ENABLE_NLS
#define _(String) String
# define _(String) String
#endif
// use C99 limit macros
#define __STDC_LIMIT_MACROS
// included here for compatibility issues with old compiler/libraries.
#ifdef HAVE_STDINT_H
#include <stdint.h>
# include <stdint.h>
#endif // HAVE_STDINT_H
// For PRId64
#define __STDC_FORMAT_MACROS
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
# include <inttypes.h>
#endif // HAVE_INTTYPES_H
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
# include <sys/types.h>
#endif
#endif // D_COMMON_H

View File

@ -35,9 +35,9 @@
#include "console.h"
#include "NullOutputFile.h"
#ifdef __MINGW32__
#include "WinConsoleFile.h"
# include "WinConsoleFile.h"
#else // !__MINGW32__
#include "BufferedFile.h"
# include "BufferedFile.h"
#endif // !__MINGW32__
namespace aria2 {

View File

@ -12,11 +12,11 @@
namespace crypto {
#if defined(__GNUG__)
#define forceinline __attribute__((always_inline)) inline
# define forceinline __attribute__((always_inline)) inline
#elif defined(_MSC_VER)
#define forceinline __forceinline
# define forceinline __forceinline
#else // ! _MSC_VER
#define forceinline inline
# define forceinline inline
#endif // ! _MSC_VER
/* In order for this implementation to work your system (or you yourself) must
@ -29,18 +29,18 @@ namespace crypto {
*/
#if defined(_WIN32) || defined(__INTEL_COMPILER) || defined(_MSC_VER)
// Itanium is dead!
#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN 4321
#define BYTE_ORDER LITTLE_ENDIAN
# define LITTLE_ENDIAN 1234
# define BIG_ENDIAN 4321
# define BYTE_ORDER LITTLE_ENDIAN
#else // ! defined(_WIN32) || defined(__INTEL_COMPILER) || defined (_MSC_VER)
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif // HAVE_SYS_PARAM_H
# ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
# endif // HAVE_SYS_PARAM_H
#endif // ! defined(_WIN32) || defined(__INTEL_COMPILER) || defined (_MSC_VER)
#if !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) || !defined(BYTE_ORDER) || \
(LITTLE_ENDIAN != BYTE_ORDER && BIG_ENDIAN != BYTE_ORDER)
#error Unsupported byte order/endianness
# error Unsupported byte order/endianness
#endif
// Lets spend some quality time mucking around with byte swap and endian-ness.
@ -52,7 +52,7 @@ forceinline uint32_t __crypto_bswap32(uint32_t p)
return p;
}
#elif defined(__GNUG__)
#define __crypto_bswap32 __builtin_bswap32
# define __crypto_bswap32 __builtin_bswap32
#else // defined(__GNUG__)
forceinline uint32_t __crypto_bswap32(uint32_t n)
{
@ -69,7 +69,7 @@ forceinline uint64_t __crypto_bswap64(uint64_t p)
return p;
}
#elif defined(__GNUG__)
#define __crypto_bswap64 __builtin_bswap64
# define __crypto_bswap64 __builtin_bswap64
#else // defined(__GNUG__)
forceinline uint64_t __crypto_bswap64(uint64_t n)
{
@ -99,11 +99,11 @@ template <> inline uint64_t __crypto_bswap(uint64_t n)
// __crypto_le and __crypto_be depending on byte order
#if LITTLE_ENDIAN == BYTE_ORDER
#define __crypto_be(n) __crypto_bswap(n)
#define __crypto_le(n) (n)
# define __crypto_be(n) __crypto_bswap(n)
# define __crypto_le(n) (n)
#else // LITTLE_ENDIAN != WORD_ORDER
#define __crypto_be(n) (n)
#define __crypto_le(n) __crypto_bswap(n)
# define __crypto_be(n) (n)
# define __crypto_le(n) __crypto_bswap(n)
#endif // LITTLE_ENDIAN != WORD_ORDER
} // namespace crypto

View File

@ -12,11 +12,11 @@
// Compiler hints
#if defined(__GNUG__)
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
# define likely(x) __builtin_expect(!!(x), 1)
# define unlikely(x) __builtin_expect(!!(x), 0)
#else // ! __GNUG_
#define likely(x) (x)
#define unlikely(x) (x)
# define likely(x) (x)
# define unlikely(x) (x)
#endif // ! __GNUG__
// Basic operations
@ -52,9 +52,9 @@ template <typename T> static forceinline T par(T b, T c, T d)
}
#ifdef __GNUG__
#define __hash_maybe_memfence __asm__("" ::: "memory")
# define __hash_maybe_memfence __asm__("" ::: "memory")
#else // __GNUG__
#define __hash_maybe_memfence
# define __hash_maybe_memfence
#endif // __GNUG__
// Template for the |::transform|s

View File

@ -38,12 +38,12 @@
#include "MemoryBufferPreDownloadHandler.h"
#include "a2functional.h"
#ifdef ENABLE_METALINK
#include "MetalinkPostDownloadHandler.h"
# include "MetalinkPostDownloadHandler.h"
#endif // ENABLE_METALINK
#ifdef ENABLE_BITTORRENT
#include "BtPostDownloadHandler.h"
#include "MemoryBencodePreDownloadHandler.h"
#include "UTMetadataPostDownloadHandler.h"
# include "BtPostDownloadHandler.h"
# include "MemoryBencodePreDownloadHandler.h"
# include "UTMetadataPostDownloadHandler.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {

View File

@ -64,9 +64,9 @@
#include "download_handlers.h"
#include "SimpleRandomizer.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
#include "BtConstants.h"
#include "ValueBaseBencodeParser.h"
# include "bittorrent_helper.h"
# include "BtConstants.h"
# include "ValueBaseBencodeParser.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {

View File

@ -29,20 +29,20 @@
#include "gai_strerror.h"
#ifdef ENABLE_NLS
#include <libintl.h>
# include <libintl.h>
#endif
#ifdef ENABLE_NLS
#define _(string) gettext(string)
#ifdef gettext_noop
#define N_(string) gettext_noop(string)
# define _(string) gettext(string)
# ifdef gettext_noop
# define N_(string) gettext_noop(string)
# else
# define N_(string) (string)
# endif
#else
#define N_(string) (string)
#endif
#else
#define gettext(string) (string)
#define _(string) (string)
#define N_(string) (string)
# define gettext(string) (string)
# define _(string) (string)
# define N_(string) (string)
#endif
/*

View File

@ -34,15 +34,15 @@ extern "C" {
#endif /* __cplusplus */
#ifdef __MINGW32__
#undef SIZE_MAX
# undef SIZE_MAX
#endif // __MINGW32__
#ifndef EAI_SYSTEM
#define EAI_SYSTEM -11 /* System error returned in `errno'. */
# define EAI_SYSTEM -11 /* System error returned in `errno'. */
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif // HAVE_CONFIG_H
/*
@ -50,7 +50,7 @@ extern "C" {
* <netdb.h> might declares all or some of them.
*/
#if defined(HAVE_GAI_STRERROR)
#define gai_strerror my_gai_strerror
# define gai_strerror my_gai_strerror
#endif
/*

View File

@ -76,66 +76,66 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif
#ifdef __MINGW32__
#include <winsock2.h>
#undef ERROR
#include <ws2tcpip.h>
# include <winsock2.h>
# undef ERROR
# include <ws2tcpip.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
# include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
# include <netdb.h>
#endif
#include <sys/types.h>
#include <stdio.h>
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#include <string.h>
#if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
#include <memory.h>
#endif /* not STDC_HEADERS and HAVE_MEMORY_H */
#else /* not STDC_HEADERS and not HAVE_STRING_H */
#include <strings.h>
# include <string.h>
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
# include <memory.h>
# endif /* not STDC_HEADERS and HAVE_MEMORY_H */
#else /* not STDC_HEADERS and not HAVE_STRING_H */
# include <strings.h>
#endif /* not STDC_HEADERS and not HAVE_STRING_H */
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
# include <stdlib.h>
#endif
#ifdef ENABLE_PTHREAD
#include <pthread.h>
# include <pthread.h>
#endif
#ifdef ENABLE_NLS
#include <libintl.h>
# include <libintl.h>
#endif
#ifndef HAVE_MEMCPY
#define memcpy(d, s, n) bcopy((s), (d), (n))
#ifdef __STDC__
# define memcpy(d, s, n) bcopy((s), (d), (n))
# ifdef __STDC__
void* memchr(const void*, int, size_t);
int memcmp(const void*, const void*, size_t);
void* memmove(void*, const void*, size_t);
void* memset(void*, int, size_t);
#else /* not __STDC__ */
# else /* not __STDC__ */
char* memchr();
int memcmp();
char* memmove();
char* memset();
#endif /* not __STDC__ */
#endif /* not HAVE_MEMCPY */
# endif /* not __STDC__ */
#endif /* not HAVE_MEMCPY */
#ifndef H_ERRNO_DECLARED
extern int h_errno;
@ -144,16 +144,16 @@ extern int h_errno;
#include "getaddrinfo.h"
#ifdef ENABLE_NLS
#define _(string) gettext(string)
#ifdef gettext_noop
#define N_(string) gettext_noop(string)
# define _(string) gettext(string)
# ifdef gettext_noop
# define N_(string) gettext_noop(string)
# else
# define N_(string) (string)
# endif
#else
#define N_(string) (string)
#endif
#else
#define gettext(string) (string)
#define _(string) (string)
#define N_(string) (string)
# define gettext(string) (string)
# define _(string) (string)
# define N_(string) (string)
#endif
/*

View File

@ -34,27 +34,27 @@ extern "C" {
#endif /* __cplusplus */
#ifdef __MINGW32__
#undef SIZE_MAX
# undef SIZE_MAX
#endif // __MINGW32__
#ifdef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif // HAVE_CONFIG_H
#ifdef __MINGW32__
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x501
#endif // _WIN32_WINNT
#include <winsock2.h>
#undef ERROR
#include <ws2tcpip.h>
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x501
# endif // _WIN32_WINNT
# include <winsock2.h>
# undef ERROR
# include <ws2tcpip.h>
#endif // __MINGW32__
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
# include <sys/socket.h>
#endif // HAVE_SYS_SOCKET_H
#ifdef HAVE_NETDB_H
#include <netdb.h>
# include <netdb.h>
#endif // HAVE_NETDB_H
#include <sys/types.h>
@ -65,88 +65,88 @@ extern "C" {
* <netdb.h> might defines some of them.
*/
#ifdef EAI_ADDRFAMILY
#undef EAI_ADDRFAMILY
# undef EAI_ADDRFAMILY
#endif
#ifdef EAI_AGAIN
#undef EAI_AGAIN
# undef EAI_AGAIN
#endif
#ifdef EAI_BADFLAGS
#undef EAI_BADFLAGS
# undef EAI_BADFLAGS
#endif
#ifdef EAI_FAIL
#undef EAI_FAIL
# undef EAI_FAIL
#endif
#ifdef EAI_FAMILY
#undef EAI_FAMILY
# undef EAI_FAMILY
#endif
#ifdef EAI_MEMORY
#undef EAI_MEMORY
# undef EAI_MEMORY
#endif
#ifdef EAI_NONAME
#undef EAI_NONAME
# undef EAI_NONAME
#endif
#ifdef EAI_OVERFLOW
#undef EAI_OVERFLOW
# undef EAI_OVERFLOW
#endif
#ifdef EAI_SERVICE
#undef EAI_SERVICE
# undef EAI_SERVICE
#endif
#ifdef EAI_SOCKTYPE
#undef EAI_SOCKTYPE
# undef EAI_SOCKTYPE
#endif
#ifdef EAI_SYSTEM
#undef EAI_SYSTEM
# undef EAI_SYSTEM
#endif
#ifdef AI_PASSIVE
#undef AI_PASSIVE
# undef AI_PASSIVE
#endif
#ifdef AI_CANONNAME
#undef AI_CANONNAME
# undef AI_CANONNAME
#endif
#ifdef AI_NUMERICHOST
#undef AI_NUMERICHOST
# undef AI_NUMERICHOST
#endif
#ifdef AI_NUMERICSERV
#undef AI_NUMERICSERV
# undef AI_NUMERICSERV
#endif
#ifdef AI_V4MAPPED
#undef AI_V4MAPPED
# undef AI_V4MAPPED
#endif
#ifdef AI_ALL
#undef AI_ALL
# undef AI_ALL
#endif
#ifdef AI_ADDRCONFIG
#undef AI_ADDRCONFIG
# undef AI_ADDRCONFIG
#endif
#ifdef AI_DEFAULT
#undef AI_DEFAULT
# undef AI_DEFAULT
#endif
#ifdef NI_NOFQDN
#undef NI_NOFQDN
# undef NI_NOFQDN
#endif
#ifdef NI_NUMERICHOST
#undef NI_NUMERICHOST
# undef NI_NUMERICHOST
#endif
#ifdef NI_NAMEREQD
#undef NI_NAMEREQD
# undef NI_NAMEREQD
#endif
#ifdef NI_NUMERICSERV
#undef NI_NUMERICSERV
# undef NI_NUMERICSERV
#endif
#ifdef NI_NUMERICSCOPE
#undef NI_NUMERICSCOPE
# undef NI_NUMERICSCOPE
#endif
#ifdef NI_DGRAM
#undef NI_DGRAM
# undef NI_DGRAM
#endif
#ifdef NI_MAXHOST
#undef NI_MAXHOST
# undef NI_MAXHOST
#endif
#ifdef NI_MAXSERV
#undef NI_MAXSERV
# undef NI_MAXSERV
#endif
/*
@ -154,11 +154,11 @@ extern "C" {
* <netdb.h> might declares all or some of them.
*/
#if defined(HAVE_GETADDRINFO) || defined(HAVE_GETNAMEINFO)
#define addrinfo my_addrinfo
#define gai_strerror my_gai_strerror
#define freeaddrinfo my_freeaddrinfo
#define getaddrinfo my_getaddrinfo
#define getnameinfo my_getnameinfo
# define addrinfo my_addrinfo
# define gai_strerror my_gai_strerror
# define freeaddrinfo my_freeaddrinfo
# define getaddrinfo my_getaddrinfo
# define getnameinfo my_getnameinfo
#endif
/* <from linux's netdb.h> */
@ -172,17 +172,17 @@ extern "C" {
0x0020 /* Use configuration of this host to choose \
returned address type.. */
#ifdef __USE_GNU
#define AI_IDN \
0x0040 /* IDN encode input (assuming it is encoded \
in the current locale's character set) \
before looking it up. */
#define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */
#define AI_IDN_ALLOW_UNASSIGNED \
0x0100 /* Don't reject unassigned Unicode \
code points. */
#define AI_IDN_USE_STD3_ASCII_RULES \
0x0200 /* Validate strings according to \
STD3 rules. */
# define AI_IDN \
0x0040 /* IDN encode input (assuming it is encoded \
in the current locale's character set) \
before looking it up. */
# define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */
# define AI_IDN_ALLOW_UNASSIGNED \
0x0100 /* Don't reject unassigned Unicode \
code points. */
# define AI_IDN_USE_STD3_ASCII_RULES \
0x0200 /* Validate strings according to \
STD3 rules. */
#endif
#define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
@ -200,12 +200,12 @@ extern "C" {
#define EAI_SYSTEM -11 /* System error returned in `errno'. */
#define EAI_OVERFLOW -12 /* Argument buffer overflow. */
#ifdef __USE_GNU
#define EAI_INPROGRESS -100 /* Processing request in progress. */
#define EAI_CANCELED -101 /* Request canceled. */
#define EAI_NOTCANCELED -102 /* Request not canceled. */
#define EAI_ALLDONE -103 /* All requests done. */
#define EAI_INTR -104 /* Interrupted by a signal. */
#define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
# define EAI_INPROGRESS -100 /* Processing request in progress. */
# define EAI_CANCELED -101 /* Request canceled. */
# define EAI_NOTCANCELED -102 /* Request not canceled. */
# define EAI_ALLDONE -103 /* All requests done. */
# define EAI_INTR -104 /* Interrupted by a signal. */
# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
#endif
#define NI_MAXHOST 1025
@ -217,13 +217,13 @@ extern "C" {
#define NI_NAMEREQD 8 /* Don't return numeric addresses. */
#define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
#ifdef __USE_GNU
#define NI_IDN 32 /* Convert name from IDN format. */
#define NI_IDN_ALLOW_UNASSIGNED \
64 /* Don't reject unassigned Unicode \
code points. */
#define NI_IDN_USE_STD3_ASCII_RULES \
128 /* Validate strings according to \
STD3 rules. */
# define NI_IDN 32 /* Convert name from IDN format. */
# define NI_IDN_ALLOW_UNASSIGNED \
64 /* Don't reject unassigned Unicode \
code points. */
# define NI_IDN_USE_STD3_ASCII_RULES \
128 /* Validate strings according to \
STD3 rules. */
#endif
/* </from linux's netdb.h> */
@ -233,10 +233,10 @@ extern "C" {
* Address families and Protocol families.
*/
#ifndef AF_UNSPEC
#define AF_UNSPEC AF_INET
# define AF_UNSPEC AF_INET
#endif
#ifndef PF_UNSPEC
#define PF_UNSPEC PF_INET
# define PF_UNSPEC PF_INET
#endif
/* Nexenta OS(GNU/Solaris OS) defines `struct addrinfo' in netdb.h */

View File

@ -27,11 +27,11 @@
#ifdef __MINGW32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
#define _W32_FT_OFFSET (116444736000000000ULL)
# define _W32_FT_OFFSET (116444736000000000ULL)
int __cdecl gettimeofday(struct timeval* __restrict__ tp,
void* __restrict__ tzp __attribute__((unused)))

View File

@ -37,11 +37,11 @@
#define _D_GETTIMEOFDAY_H 1
#ifdef __MINGW32__
#undef SIZE_MAX
# undef SIZE_MAX
#endif // __MINGW32__
#ifdef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif // HAVE_CONFIG_H
#include <sys/time.h>

View File

@ -38,9 +38,9 @@
#include <libgen.h>
#if defined(__CYGWIN__) || defined(__DJGPP__) || defined(__MINGW32__)
#define IS_PATH_SEPARATOR(c) (((c) == '/') || ((c) == '\\'))
# define IS_PATH_SEPARATOR(c) (((c) == '/') || ((c) == '\\'))
#else
#define IS_PATH_SEPARATOR(c) ((c) == '/')
# define IS_PATH_SEPARATOR(c) ((c) == '/')
#endif
/* per http://www.scit.wlv.ac.uk/cgi-bin/mansec?3C+basename */

View File

@ -38,9 +38,9 @@
#include <openssl/opensslv.h>
#if defined(LIBRESSL_VERSION_NUMBER)
#define LIBRESSL_IN_USE 1
# define LIBRESSL_IN_USE 1
#else // !defined(LIBRESSL_VERSION_NUMBER)
#define LIBRESSL_IN_USE 0
# define LIBRESSL_IN_USE 0
#endif // !defined(LIBRESSL_VERSION_NUMBER)
#define OPENSSL_101_API \

View File

@ -37,8 +37,8 @@
#include <stdlib.h>
#ifdef __MINGW32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif // __MINGW32__
#include "localtime_r.h"

View File

@ -37,7 +37,7 @@
#include <unistd.h>
#ifdef __MINGW32__
#include <shellapi.h>
# include <shellapi.h>
#endif // __MINGW32__
#include <aria2/aria2.h>

View File

@ -61,7 +61,7 @@
#include "array_fun.h"
#include "LogFactory.h"
#ifndef HAVE_DAEMON
#include "daemon.h"
# include "daemon.h"
#endif // !HAVE_DAEMON
namespace aria2 {
@ -322,12 +322,12 @@ error_code::Value option_processing(Option& op, bool standalone,
#if defined(__GNUC__) && defined(__APPLE__)
// daemon() is deprecated on OSX since... forever.
// Silence the warning for good, so that -Werror becomes feasible.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif // defined(__GNUC__) && defined(__APPLE__)
const auto daemonized = daemon(0, 0);
#if defined(__GNUC__) && defined(__APPLE__)
#pragma GCC diagnostic pop
# pragma GCC diagnostic pop
#endif // defined(__GNUC__) && defined(__APPLE__)
if (daemonized < 0) {

View File

@ -31,15 +31,15 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
#ifndef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif // HAVE_CONFIG_H
#ifndef HAVE_LOCALTIME_R
#include "localtime_r.h"
# include "localtime_r.h"
#endif // HAVE_LOCALTIME_R
#ifndef HAVE_TIMEGM
#include "timegm.h"
# include "timegm.h"
#endif // HAVE_TIMEGM
#include <stddef.h>
@ -50,11 +50,11 @@
#include <stdlib.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
# include <alloca.h>
#endif // HAVE_ALLOCA_H
#ifdef HAVE_MALLOC_H
#include <malloc.h>
# include <malloc.h>
#endif // HAVE_MALLOC_H
#include "strptime.h"

View File

@ -35,7 +35,7 @@
#define D_TIMEGM_H
#ifdef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif // HAVE_CONFIG_H
#ifdef __cplusplus

View File

@ -36,21 +36,21 @@
#ifdef __sun
// For opensolaris, just include signal.h which includes sys/signal.h
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif // HAVE_SIGNAL_H
#else // !__sun
#ifdef HAVE_SYS_SIGNAL_H
#include <sys/signal.h>
#endif // HAVE_SYS_SIGNAL_H
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif // HAVE_SIGNAL_H
#endif // !__sun
# ifdef HAVE_SIGNAL_H
# include <signal.h>
# endif // HAVE_SIGNAL_H
#else // !__sun
# ifdef HAVE_SYS_SIGNAL_H
# include <sys/signal.h>
# endif // HAVE_SYS_SIGNAL_H
# ifdef HAVE_SIGNAL_H
# include <signal.h>
# endif // HAVE_SIGNAL_H
#endif // !__sun
#include <sys/types.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
# include <pwd.h>
#endif // HAVE_PWD_H
#include <array>
@ -91,7 +91,7 @@
// For libc6 which doesn't define ULLONG_MAX properly because of broken limits.h
#ifndef ULLONG_MAX
#define ULLONG_MAX 18446744073709551615ULL
# define ULLONG_MAX 18446744073709551615ULL
#endif // ULLONG_MAX
namespace aria2 {
@ -1749,12 +1749,12 @@ std::string getHomeDir()
if (p) {
return p;
}
#ifdef HAVE_PWD_H
# ifdef HAVE_PWD_H
auto pw = getpwuid(geteuid());
if (pw && pw->pw_dir) {
return pw->pw_dir;
}
#endif // HAVE_PWD_H
# endif // HAVE_PWD_H
return A2STR::NIL;
}
@ -1894,7 +1894,7 @@ void sleep(long seconds)
#elif defined(HAVE_USLEEP)
::usleep(seconds * 1000000);
#else
#error no sleep function is available (nanosleep?)
# error no sleep function is available (nanosleep?)
#endif
}
@ -1935,7 +1935,7 @@ void usleep(long microseconds)
if (msec)
Sleep(msec);
#else
#error no usleep function is available (nanosleep?)
# error no usleep function is available (nanosleep?)
#endif
}

View File

@ -65,11 +65,11 @@
#include "prefs.h"
#ifdef ENABLE_SSL
#include "TLSContext.h"
# include "TLSContext.h"
#endif // ENABLE_SSL
#ifndef HAVE_SIGACTION
#define sigset_t int
# define sigset_t int
#endif // HAVE_SIGACTION
namespace aria2 {
@ -105,8 +105,8 @@ std::string wCharToUtf8(const std::wstring& wsrc);
// replace any backslash '\' in |src| with '/' and returns it.
std::string toForwardSlash(const std::string& src);
#else // !__MINGW32__
#define utf8ToWChar(src) src
#define utf8ToNative(src) src
# define utf8ToWChar(src) src
# define utf8ToNative(src) src
#endif // !__MINGW32__
namespace util {

View File

@ -79,11 +79,11 @@ void Aria2ApiTest::testAddMetalink()
KeyVals options;
#ifdef ENABLE_METALINK
CPPUNIT_ASSERT_EQUAL(0, addMetalink(session_, &gids, metalinkPath, options));
#ifdef ENABLE_BITTORRENT
# ifdef ENABLE_BITTORRENT
CPPUNIT_ASSERT_EQUAL((size_t)2, gids.size());
#else // !ENABLE_BITTORRENT
# else // !ENABLE_BITTORRENT
CPPUNIT_ASSERT_EQUAL((size_t)1, gids.size());
#endif // !ENABLE_BITTORRENT
# endif // !ENABLE_BITTORRENT
gids.clear();
options.push_back(KeyVals::value_type("file-allocation", "foo"));

View File

@ -14,9 +14,9 @@
#include "FileEntry.h"
#include "array_fun.h"
#ifdef ENABLE_BITTORRENT
#include "MockPeerStorage.h"
#include "BtRuntime.h"
#include "bittorrent_helper.h"
# include "MockPeerStorage.h"
# include "BtRuntime.h"
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {
@ -27,10 +27,10 @@ class DefaultBtProgressInfoFileTest : public CppUnit::TestFixture {
#ifdef ENABLE_BITTORRENT
CPPUNIT_TEST(testSave);
CPPUNIT_TEST(testLoad);
#ifndef WORDS_BIGENDIAN
# ifndef WORDS_BIGENDIAN
CPPUNIT_TEST(testLoad_compat);
#endif // !WORDS_BIGENDIAN
#endif // ENABLE_BITTORRENT
# endif // !WORDS_BIGENDIAN
#endif // ENABLE_BITTORRENT
CPPUNIT_TEST(testSave_nonBt);
CPPUNIT_TEST(testLoad_nonBt);
#ifndef WORDS_BIGENDIAN
@ -89,10 +89,10 @@ public:
#ifdef ENABLE_BITTORRENT
void testSave();
void testLoad();
#ifndef WORDS_BIGENDIAN
# ifndef WORDS_BIGENDIAN
void testLoad_compat();
#endif // !WORDS_BIGENDIAN
#endif // ENABLE_BITTORRENT
# endif // !WORDS_BIGENDIAN
#endif // ENABLE_BITTORRENT
void testSave_nonBt();
void testLoad_nonBt();
#ifndef WORDS_BIGENDIAN
@ -111,7 +111,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DefaultBtProgressInfoFileTest);
// Because load.aria2 is made for little endian systems, exclude
// testLoad_compat() for big endian systems.
#ifndef WORDS_BIGENDIAN
# ifndef WORDS_BIGENDIAN
void DefaultBtProgressInfoFileTest::testLoad_compat()
{
initializeMembers(1_k, 80_k);
@ -159,7 +159,7 @@ void DefaultBtProgressInfoFileTest::testLoad_compat()
CPPUNIT_ASSERT_EQUAL((size_t)2, piece2->getIndex());
CPPUNIT_ASSERT_EQUAL((int64_t)512, piece2->getLength());
}
#endif // !WORDS_BIGENDIAN
# endif // !WORDS_BIGENDIAN
void DefaultBtProgressInfoFileTest::testLoad()
{

View File

@ -15,7 +15,7 @@
#include "util.h"
#include "FileEntry.h"
#ifdef ENABLE_BITTORRENT
#include "bittorrent_helper.h"
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
namespace aria2 {
@ -215,11 +215,11 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink()
// group1: http://alpha/file, ...
// group2-7: 6 file entry in Metalink and 1 torrent file download
#ifdef ENABLE_BITTORRENT
# ifdef ENABLE_BITTORRENT
CPPUNIT_ASSERT_EQUAL((size_t)7, result.size());
#else // !ENABLE_BITTORRENT
# else // !ENABLE_BITTORRENT
CPPUNIT_ASSERT_EQUAL((size_t)6, result.size());
#endif // !ENABLE_BITTORRENT
# endif // !ENABLE_BITTORRENT
std::shared_ptr<RequestGroup> group = result[0];
auto xuris = group->getDownloadContext()->getFirstFileEntry()->getUris();
@ -349,11 +349,11 @@ void DownloadHelperTest::testCreateRequestGroupForMetalink()
createRequestGroupForMetalink(result, option_);
#ifdef ENABLE_BITTORRENT
# ifdef ENABLE_BITTORRENT
CPPUNIT_ASSERT_EQUAL((size_t)6, result.size());
#else // !ENABLE_BITTORRENT
# else // !ENABLE_BITTORRENT
CPPUNIT_ASSERT_EQUAL((size_t)5, result.size());
#endif // !ENABLE_BITTORRENT
# endif // !ENABLE_BITTORRENT
std::shared_ptr<RequestGroup> group = result[0];
auto uris = group->getDownloadContext()->getFirstFileEntry()->getUris();
std::sort(uris.begin(), uris.end());

View File

@ -209,7 +209,7 @@ void Metalink2RequestGroupTest::testGenerate_groupByMetaurl()
void Metalink2RequestGroupTest::testGenerate_dosDirTraversal()
{
#ifdef __MINGW32__
#ifdef ENABLE_BITTORRENT
# ifdef ENABLE_BITTORRENT
std::vector<std::shared_ptr<RequestGroup>> groups;
option_->put(PREF_DIR, "/tmp");
Metalink2RequestGroup().generate(
@ -228,8 +228,8 @@ void Metalink2RequestGroupTest::testGenerate_dosDirTraversal()
file = rg->getDownloadContext()->getFileEntries()[1];
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/..%5C..%5Cfile2.ext"),
file->getPath());
#endif // ENABLE_BITTORRENT
#endif // __MINGW32__
# endif // ENABLE_BITTORRENT
#endif // __MINGW32__
}
} // namespace aria2

View File

@ -1,11 +1,11 @@
#ifndef D_MOCK_PEER_STORAGE_H
#define D_MOCK_PEER_STORAGE_H
# define D_MOCK_PEER_STORAGE_H
#include "PeerStorage.h"
# include "PeerStorage.h"
#include <algorithm>
# include <algorithm>
#include "Peer.h"
# include "Peer.h"
namespace aria2 {

View File

@ -5,7 +5,7 @@
#include "RpcRequest.h"
#include "RecoverableException.h"
#ifdef ENABLE_XML_RPC
#include "XmlRpcRequestParserStateMachine.h"
# include "XmlRpcRequestParserStateMachine.h"
#endif // ENABLE_XML_RPC
namespace aria2 {

Some files were not shown because too many files have changed in this diff Show More