From e976b23728d3d1fc1047cd00fef42ed8013bb295 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 22 Oct 2009 15:35:33 +0000 Subject: 2009-10-23 Tatsuhiro Tsujikawa Renamed Util.{cc,h} as util.{cc,h} * src/Util.cc * src/Util.h * src/util.cc * src/util.h --- ChangeLog | 8 + src/AbstractCommand.cc | 2 +- src/AbstractDiskWriter.cc | 2 +- src/AnnounceList.cc | 2 +- src/AsyncNameResolver.cc | 2 +- src/AuthConfigFactory.cc | 2 +- src/BitfieldMan.cc | 2 +- src/BtBitfieldMessage.cc | 2 +- src/BtDependency.cc | 2 +- src/BtExtendedMessage.cc | 2 +- src/BtHandshakeMessage.cc | 2 +- src/BtHandshakeMessageValidator.h | 2 +- src/BtPieceMessage.cc | 2 +- src/BtPortMessage.cc | 2 +- src/BtPostDownloadHandler.cc | 2 +- src/BtSetup.cc | 2 +- src/ByteArrayDiskWriter.cc | 2 +- src/ChunkedDecoder.cc | 2 +- src/ConsoleStatCalc.cc | 2 +- src/ContentTypeRequestGroupCriteria.cc | 2 +- src/Cookie.cc | 2 +- src/CookieParser.cc | 2 +- src/CookieStorage.cc | 2 +- src/DHTAbstractNodeLookupTask.cc | 2 +- src/DHTAbstractTask.cc | 2 +- src/DHTAnnouncePeerMessage.cc | 2 +- src/DHTAutoSaveCommand.cc | 2 +- src/DHTBucket.cc | 2 +- src/DHTBucketRefreshTask.cc | 2 +- src/DHTConnectionImpl.cc | 2 +- src/DHTEntryPointNameResolveCommand.cc | 2 +- src/DHTFindNodeMessage.cc | 2 +- src/DHTFindNodeReplyMessage.cc | 2 +- src/DHTGetPeersMessage.cc | 2 +- src/DHTGetPeersReplyMessage.cc | 2 +- src/DHTMessage.cc | 2 +- src/DHTMessageFactoryImpl.cc | 2 +- src/DHTMessageReceiver.cc | 2 +- src/DHTMessageTracker.cc | 2 +- src/DHTMessageTrackerEntry.cc | 2 +- src/DHTNode.cc | 2 +- src/DHTNodeLookupTask.cc | 2 +- src/DHTPeerAnnounceStorage.cc | 2 +- src/DHTPeerLookupTask.cc | 2 +- src/DHTQueryMessage.cc | 2 +- src/DHTResponseMessage.cc | 2 +- src/DHTRoutingTable.cc | 2 +- src/DHTRoutingTableDeserializer.cc | 2 +- src/DHTRoutingTableSerializer.cc | 2 +- src/DHTSetup.cc | 2 +- src/DHTTokenTracker.cc | 2 +- src/DHTUnknownMessage.cc | 2 +- src/DefaultBtAnnounce.cc | 2 +- src/DefaultBtInteractive.cc | 2 +- src/DefaultBtProgressInfoFile.cc | 2 +- src/DefaultPieceStorage.cc | 2 +- src/DownloadCommand.cc | 2 +- src/DownloadEngine.cc | 2 +- src/ExpatMetalinkProcessor.cc | 2 +- src/ExpatXmlRpcRequestProcessor.cc | 2 +- src/FeatureConfig.cc | 2 +- src/File.cc | 2 +- src/FileAllocationCommand.cc | 2 +- src/FileEntry.cc | 2 +- src/FixedWidthNumberDecorator.h | 2 +- src/FtpConnection.cc | 2 +- src/FtpNegotiationCommand.cc | 2 +- src/HandshakeExtensionMessage.cc | 2 +- src/HttpConnection.cc | 2 +- src/HttpHeader.cc | 2 +- src/HttpHeaderProcessor.cc | 2 +- src/HttpRequest.cc | 2 +- src/HttpRequestCommand.cc | 2 +- src/HttpResponse.cc | 2 +- src/HttpResponseCommand.cc | 2 +- src/HttpServer.cc | 2 +- src/HttpServerCommand.cc | 2 +- src/HttpSkipResponseCommand.cc | 2 +- src/IndexBtMessage.cc | 2 +- src/IteratableChecksumValidator.cc | 2 +- src/IteratableChunkChecksumValidator.cc | 2 +- src/MSEHandshake.cc | 2 +- src/Makefile.am | 2 +- src/Makefile.in | 8 +- src/MessageDigestHelper.cc | 2 +- src/Metalink2RequestGroup.cc | 2 +- src/MetalinkEntry.cc | 2 +- src/MetalinkParserController.cc | 2 +- src/MetalinkParserStateImpl.cc | 2 +- src/MultiDiskAdaptor.cc | 2 +- src/MultiUrlRequestInfo.cc | 2 +- src/NameMatchOptionHandler.h | 2 +- src/NameResolver.cc | 2 +- src/Netrc.cc | 2 +- src/NsCookieParser.cc | 2 +- src/OptionHandlerFactory.cc | 2 +- src/OptionHandlerImpl.h | 2 +- src/OptionParser.cc | 2 +- src/ParameterizedStringParser.cc | 2 +- src/Peer.cc | 2 +- src/PeerReceiveHandshakeCommand.cc | 2 +- src/Piece.cc | 4 +- src/RangeBtMessage.cc | 2 +- src/Request.cc | 2 +- src/RequestGroup.cc | 2 +- src/RequestGroupMan.cc | 2 +- src/RequestSlot.cc | 2 +- src/SegmentMan.cc | 2 +- src/ServerStatMan.cc | 2 +- src/SimpleLogger.cc | 2 +- src/SingleFileAllocationIterator.cc | 2 +- src/SocketCore.cc | 2 +- src/Sqlite3MozCookieParser.cc | 2 +- src/TimeA2.cc | 2 +- src/UTPexExtensionMessage.cc | 2 +- src/UriListParser.cc | 2 +- src/Util.cc | 845 -------------------------------- src/Util.h | 327 ------------ src/XML2SAXMetalinkProcessor.cc | 2 +- src/Xml2XmlRpcRequestProcessor.cc | 2 +- src/XmlRpcMethodImpl.cc | 2 +- src/XmlRpcRequestParserStateImpl.cc | 2 +- src/XmlRpcResponse.cc | 2 +- src/bitfield.h | 2 +- src/bittorrent_helper.cc | 2 +- src/bittorrent_helper.h | 2 +- src/download_helper.cc | 2 +- src/main.cc | 2 +- src/messageDigest.cc | 2 +- src/option_processing.cc | 2 +- src/util.cc | 845 ++++++++++++++++++++++++++++++++ src/util.h | 327 ++++++++++++ src/version_usage.cc | 2 +- test/ARC4Test.cc | 2 +- test/BDETest.cc | 2 +- test/BNodeTest.cc | 2 +- test/BittorrentHelperTest.cc | 2 +- test/BtAllowedFastMessageTest.cc | 2 +- test/BtBitfieldMessageTest.cc | 2 +- test/BtHandshakeMessageTest.cc | 2 +- test/BtPortMessageTest.cc | 2 +- test/CookieStorageTest.cc | 2 +- test/CookieTest.cc | 2 +- test/DHKeyExchangeTest.cc | 2 +- test/DHTAnnouncePeerMessageTest.cc | 2 +- test/DHTAnnouncePeerReplyMessageTest.cc | 2 +- test/DHTBucketTest.cc | 2 +- test/DHTFindNodeMessageTest.cc | 2 +- test/DHTFindNodeReplyMessageTest.cc | 2 +- test/DHTGetPeersMessageTest.cc | 2 +- test/DHTGetPeersReplyMessageTest.cc | 2 +- test/DHTIDCloserTest.cc | 2 +- test/DHTMessageFactoryImplTest.cc | 2 +- test/DHTMessageTrackerEntryTest.cc | 2 +- test/DHTMessageTrackerTest.cc | 2 +- test/DHTNodeTest.cc | 2 +- test/DHTPeerAnnounceEntryTest.cc | 2 +- test/DHTPeerAnnounceStorageTest.cc | 2 +- test/DHTPingMessageTest.cc | 2 +- test/DHTPingReplyMessageTest.cc | 2 +- test/DHTRoutingTableDeserializerTest.cc | 2 +- test/DHTRoutingTableSerializerTest.cc | 2 +- test/DHTRoutingTableTest.cc | 2 +- test/DHTTokenTrackerTest.cc | 2 +- test/DefaultBtAnnounceTest.cc | 2 +- test/DefaultBtMessageDispatcherTest.cc | 2 +- test/DefaultBtProgressInfoFileTest.cc | 2 +- test/DefaultPeerStorageTest.cc | 2 +- test/DefaultPieceStorageTest.cc | 2 +- test/DirectDiskAdaptorTest.cc | 2 +- test/DownloadHelperTest.cc | 2 +- test/FeatureConfigTest.cc | 2 +- test/FeedbackURISelectorTest.cc | 2 +- test/FtpConnectionTest.cc | 2 +- test/GZipDecoderTest.cc | 2 +- test/HttpRequestTest.cc | 2 +- test/InOrderURISelectorTest.cc | 2 +- test/MSEHandshakeTest.cc | 2 +- test/MessageDigestHelperTest.cc | 2 +- test/NsCookieParserTest.cc | 2 +- test/OptionParserTest.cc | 2 +- test/PeerSessionResourceTest.cc | 2 +- test/ProtocolDetectorTest.cc | 2 +- test/ServerStatManTest.cc | 2 +- test/ServerStatTest.cc | 2 +- test/Sqlite3MozCookieParserTest.cc | 2 +- test/StringFormatTest.cc | 2 +- test/TimeSeedCriteriaTest.cc | 2 +- test/TimeTest.cc | 2 +- test/UTPexExtensionMessageTest.cc | 2 +- test/UriListParserTest.cc | 2 +- test/UtilTest.cc | 2 +- test/XORCloserTest.cc | 2 +- 193 files changed, 1372 insertions(+), 1364 deletions(-) delete mode 100644 src/Util.cc delete mode 100644 src/Util.h create mode 100644 src/util.cc create mode 100644 src/util.h diff --git a/ChangeLog b/ChangeLog index 7396c41a..7ef8a29c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-10-23 Tatsuhiro Tsujikawa + + Renamed Util.{cc,h} as util.{cc,h} + * src/Util.cc + * src/Util.h + * src/util.cc + * src/util.h + 2009-10-22 Tatsuhiro Tsujikawa Moved static functions in Util class to namespace util. diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index a0774350..71ebe860 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -61,7 +61,7 @@ #include "ServerStat.h" #include "RequestGroupMan.h" #include "A2STR.h" -#include "Util.h" +#include "util.h" #include "LogFactory.h" #include "DownloadContext.h" diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index 0491b896..78e9ffed 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -45,7 +45,7 @@ #endif // __MINGW32__ #include "File.h" -#include "Util.h" +#include "util.h" #include "message.h" #include "LogFactory.h" #include "Logger.h" diff --git a/src/AnnounceList.cc b/src/AnnounceList.cc index b98825aa..67260a98 100644 --- a/src/AnnounceList.cc +++ b/src/AnnounceList.cc @@ -39,7 +39,7 @@ #include "A2STR.h" #include "SimpleRandomizer.h" #include "bencode.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/AsyncNameResolver.cc b/src/AsyncNameResolver.cc index 9546b6c8..62f826ae 100644 --- a/src/AsyncNameResolver.cc +++ b/src/AsyncNameResolver.cc @@ -33,7 +33,7 @@ */ /* copyright --> */ #include "AsyncNameResolver.h" -#include "Util.h" +#include "util.h" #include "A2STR.h" #include diff --git a/src/AuthConfigFactory.cc b/src/AuthConfigFactory.cc index dd9c0a79..c3dfc823 100644 --- a/src/AuthConfigFactory.cc +++ b/src/AuthConfigFactory.cc @@ -43,7 +43,7 @@ #include "NetrcAuthResolver.h" #include "prefs.h" #include "Request.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/BitfieldMan.cc b/src/BitfieldMan.cc index 70776894..94cec879 100644 --- a/src/BitfieldMan.cc +++ b/src/BitfieldMan.cc @@ -38,7 +38,7 @@ #include #include "Randomizer.h" -#include "Util.h" +#include "util.h" #include "array_fun.h" #include "bitfield.h" diff --git a/src/BtBitfieldMessage.cc b/src/BtBitfieldMessage.cc index 9451cf5d..40972105 100644 --- a/src/BtBitfieldMessage.cc +++ b/src/BtBitfieldMessage.cc @@ -37,7 +37,7 @@ #include #include "bittorrent_helper.h" -#include "Util.h" +#include "util.h" #include "DlAbortEx.h" #include "message.h" #include "Peer.h" diff --git a/src/BtDependency.cc b/src/BtDependency.cc index 936923d4..6041a9ef 100644 --- a/src/BtDependency.cc +++ b/src/BtDependency.cc @@ -41,7 +41,7 @@ #include "RecoverableException.h" #include "message.h" #include "prefs.h" -#include "Util.h" +#include "util.h" #include "PieceStorage.h" #include "DiskAdaptor.h" #include "File.h" diff --git a/src/BtExtendedMessage.cc b/src/BtExtendedMessage.cc index 913085ca..eec37cda 100644 --- a/src/BtExtendedMessage.cc +++ b/src/BtExtendedMessage.cc @@ -43,7 +43,7 @@ #include "Peer.h" #include "DlAbortEx.h" #include "message.h" -#include "Util.h" +#include "util.h" #include "StringFormat.h" #include "a2functional.h" diff --git a/src/BtHandshakeMessage.cc b/src/BtHandshakeMessage.cc index 1be54862..aaf8b643 100644 --- a/src/BtHandshakeMessage.cc +++ b/src/BtHandshakeMessage.cc @@ -36,7 +36,7 @@ #include -#include "Util.h" +#include "util.h" #include "BtConstants.h" #include "a2functional.h" diff --git a/src/BtHandshakeMessageValidator.h b/src/BtHandshakeMessageValidator.h index 59a4ce0f..8e618650 100644 --- a/src/BtHandshakeMessageValidator.h +++ b/src/BtHandshakeMessageValidator.h @@ -40,7 +40,7 @@ #include #include "BtHandshakeMessage.h" -#include "Util.h" +#include "util.h" #include "StringFormat.h" namespace aria2 { diff --git a/src/BtPieceMessage.cc b/src/BtPieceMessage.cc index 4ff4e897..c97e570b 100644 --- a/src/BtPieceMessage.cc +++ b/src/BtPieceMessage.cc @@ -39,7 +39,7 @@ #include #include "bittorrent_helper.h" -#include "Util.h" +#include "util.h" #include "message.h" #include "DlAbortEx.h" #include "MessageDigestHelper.h" diff --git a/src/BtPortMessage.cc b/src/BtPortMessage.cc index 28a4a8d3..8baf0c0f 100644 --- a/src/BtPortMessage.cc +++ b/src/BtPortMessage.cc @@ -35,7 +35,7 @@ #include "BtPortMessage.h" #include "bittorrent_helper.h" #include "DlAbortEx.h" -#include "Util.h" +#include "util.h" #include "message.h" #include "Logger.h" #include "Peer.h" diff --git a/src/BtPostDownloadHandler.cc b/src/BtPostDownloadHandler.cc index 2888495e..fa0b8b2e 100644 --- a/src/BtPostDownloadHandler.cc +++ b/src/BtPostDownloadHandler.cc @@ -41,7 +41,7 @@ #include "File.h" #include "PieceStorage.h" #include "DiskAdaptor.h" -#include "Util.h" +#include "util.h" #include "ContentTypeRequestGroupCriteria.h" #include "Exception.h" #include "DownloadContext.h" diff --git a/src/BtSetup.cc b/src/BtSetup.cc index 67775860..d2242ccf 100644 --- a/src/BtSetup.cc +++ b/src/BtSetup.cc @@ -49,7 +49,7 @@ #include "prefs.h" #include "LogFactory.h" #include "Logger.h" -#include "Util.h" +#include "util.h" #include "IntSequence.h" #include "DHTGetPeersCommand.h" #include "DHTPeerAnnounceStorage.h" diff --git a/src/ByteArrayDiskWriter.cc b/src/ByteArrayDiskWriter.cc index 612f9db1..5849142b 100644 --- a/src/ByteArrayDiskWriter.cc +++ b/src/ByteArrayDiskWriter.cc @@ -33,7 +33,7 @@ */ /* copyright --> */ #include "ByteArrayDiskWriter.h" -#include "Util.h" +#include "util.h" #include "A2STR.h" namespace aria2 { diff --git a/src/ChunkedDecoder.cc b/src/ChunkedDecoder.cc index 77462fe8..a18f3fd9 100644 --- a/src/ChunkedDecoder.cc +++ b/src/ChunkedDecoder.cc @@ -33,7 +33,7 @@ */ /* copyright --> */ #include "ChunkedDecoder.h" -#include "Util.h" +#include "util.h" #include "message.h" #include "DlAbortEx.h" #include "StringFormat.h" diff --git a/src/ConsoleStatCalc.cc b/src/ConsoleStatCalc.cc index 5219f35e..fca59adc 100644 --- a/src/ConsoleStatCalc.cc +++ b/src/ConsoleStatCalc.cc @@ -56,7 +56,7 @@ #include "FileAllocationEntry.h" #include "CheckIntegrityMan.h" #include "CheckIntegrityEntry.h" -#include "Util.h" +#include "util.h" #include "DownloadContext.h" #ifdef ENABLE_BITTORRENT # include "bittorrent_helper.h" diff --git a/src/ContentTypeRequestGroupCriteria.cc b/src/ContentTypeRequestGroupCriteria.cc index ce3a3a2f..8f726332 100644 --- a/src/ContentTypeRequestGroupCriteria.cc +++ b/src/ContentTypeRequestGroupCriteria.cc @@ -37,7 +37,7 @@ #include #include "RequestGroup.h" -#include "Util.h" +#include "util.h" #include "FileEntry.h" #include "DownloadContext.h" diff --git a/src/Cookie.cc b/src/Cookie.cc index 3d16b9e0..e541623d 100644 --- a/src/Cookie.cc +++ b/src/Cookie.cc @@ -37,7 +37,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "A2STR.h" #include "TimeA2.h" #include "a2functional.h" diff --git a/src/CookieParser.cc b/src/CookieParser.cc index 1a9d5be9..55112392 100644 --- a/src/CookieParser.cc +++ b/src/CookieParser.cc @@ -41,7 +41,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "A2STR.h" #include "TimeA2.h" diff --git a/src/CookieStorage.cc b/src/CookieStorage.cc index e716bd85..793e6213 100644 --- a/src/CookieStorage.cc +++ b/src/CookieStorage.cc @@ -38,7 +38,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "LogFactory.h" #include "Logger.h" #include "DlAbortEx.h" diff --git a/src/DHTAbstractNodeLookupTask.cc b/src/DHTAbstractNodeLookupTask.cc index fbee6455..f4752b0c 100644 --- a/src/DHTAbstractNodeLookupTask.cc +++ b/src/DHTAbstractNodeLookupTask.cc @@ -43,7 +43,7 @@ #include "DHTBucket.h" #include "LogFactory.h" #include "Logger.h" -#include "Util.h" +#include "util.h" #include "DHTIDCloser.h" #include #include diff --git a/src/DHTAbstractTask.cc b/src/DHTAbstractTask.cc index 9e6c4f52..3665d71e 100644 --- a/src/DHTAbstractTask.cc +++ b/src/DHTAbstractTask.cc @@ -42,7 +42,7 @@ #include "DHTBucket.h" #include "DHTTaskQueue.h" #include "LogFactory.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/DHTAnnouncePeerMessage.cc b/src/DHTAnnouncePeerMessage.cc index 07ef5178..6eaeb032 100644 --- a/src/DHTAnnouncePeerMessage.cc +++ b/src/DHTAnnouncePeerMessage.cc @@ -41,7 +41,7 @@ #include "DHTMessageFactory.h" #include "DHTMessageDispatcher.h" #include "DHTMessageCallback.h" -#include "Util.h" +#include "util.h" #include "DHTPeerAnnounceStorage.h" #include "DHTTokenTracker.h" #include "DlAbortEx.h" diff --git a/src/DHTAutoSaveCommand.cc b/src/DHTAutoSaveCommand.cc index 11247a1b..c376bb3a 100644 --- a/src/DHTAutoSaveCommand.cc +++ b/src/DHTAutoSaveCommand.cc @@ -44,7 +44,7 @@ #include "DHTRoutingTableSerializer.h" #include "RecoverableException.h" #include "DownloadEngine.h" -#include "Util.h" +#include "util.h" #include "DHTBucket.h" #include "RequestGroupMan.h" #include "prefs.h" diff --git a/src/DHTBucket.cc b/src/DHTBucket.cc index abcdb53d..e838b522 100644 --- a/src/DHTBucket.cc +++ b/src/DHTBucket.cc @@ -41,7 +41,7 @@ #include "DHTNode.h" #include "LogFactory.h" #include "Logger.h" -#include "Util.h" +#include "util.h" #include "DHTConstants.h" #include "a2functional.h" #include "bittorrent_helper.h" diff --git a/src/DHTBucketRefreshTask.cc b/src/DHTBucketRefreshTask.cc index 90a743fe..47af91fc 100644 --- a/src/DHTBucketRefreshTask.cc +++ b/src/DHTBucketRefreshTask.cc @@ -39,7 +39,7 @@ #include "DHTTaskQueue.h" #include "DHTNode.h" #include "DHTNodeLookupEntry.h" -#include "Util.h" +#include "util.h" #include "Logger.h" namespace aria2 { diff --git a/src/DHTConnectionImpl.cc b/src/DHTConnectionImpl.cc index 96088ab3..5d22481d 100644 --- a/src/DHTConnectionImpl.cc +++ b/src/DHTConnectionImpl.cc @@ -41,7 +41,7 @@ #include "LogFactory.h" #include "Logger.h" #include "RecoverableException.h" -#include "Util.h" +#include "util.h" #include "Socket.h" #include "SimpleRandomizer.h" diff --git a/src/DHTEntryPointNameResolveCommand.cc b/src/DHTEntryPointNameResolveCommand.cc index dbe9ae9a..9ff27565 100644 --- a/src/DHTEntryPointNameResolveCommand.cc +++ b/src/DHTEntryPointNameResolveCommand.cc @@ -41,7 +41,7 @@ #include "DlAbortEx.h" #include "prefs.h" #include "message.h" -#include "Util.h" +#include "util.h" #include "Option.h" #include "DHTNode.h" #include "DHTTaskQueue.h" diff --git a/src/DHTFindNodeMessage.cc b/src/DHTFindNodeMessage.cc index f35c40dd..bd722044 100644 --- a/src/DHTFindNodeMessage.cc +++ b/src/DHTFindNodeMessage.cc @@ -41,7 +41,7 @@ #include "DHTMessageFactory.h" #include "DHTMessageDispatcher.h" #include "DHTMessageCallback.h" -#include "Util.h" +#include "util.h" #include "bencode.h" namespace aria2 { diff --git a/src/DHTFindNodeReplyMessage.cc b/src/DHTFindNodeReplyMessage.cc index cadab099..64a78a0b 100644 --- a/src/DHTFindNodeReplyMessage.cc +++ b/src/DHTFindNodeReplyMessage.cc @@ -43,7 +43,7 @@ #include "DHTMessageDispatcher.h" #include "DHTMessageCallback.h" #include "bittorrent_helper.h" -#include "Util.h" +#include "util.h" #include "bencode.h" namespace aria2 { diff --git a/src/DHTGetPeersMessage.cc b/src/DHTGetPeersMessage.cc index 20f58ee0..0e814a42 100644 --- a/src/DHTGetPeersMessage.cc +++ b/src/DHTGetPeersMessage.cc @@ -44,7 +44,7 @@ #include "DHTPeerAnnounceStorage.h" #include "Peer.h" #include "DHTTokenTracker.h" -#include "Util.h" +#include "util.h" #include "bencode.h" namespace aria2 { diff --git a/src/DHTGetPeersReplyMessage.cc b/src/DHTGetPeersReplyMessage.cc index 2f096610..ad6a02cb 100644 --- a/src/DHTGetPeersReplyMessage.cc +++ b/src/DHTGetPeersReplyMessage.cc @@ -44,7 +44,7 @@ #include "DHTMessageCallback.h" #include "bittorrent_helper.h" #include "Peer.h" -#include "Util.h" +#include "util.h" #include "bencode.h" #include "a2functional.h" diff --git a/src/DHTMessage.cc b/src/DHTMessage.cc index 86f51e2a..515e6d5d 100644 --- a/src/DHTMessage.cc +++ b/src/DHTMessage.cc @@ -34,7 +34,7 @@ /* copyright --> */ #include "DHTMessage.h" #include "DHTNode.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/DHTMessageFactoryImpl.cc b/src/DHTMessageFactoryImpl.cc index 36e78901..bf95ff1a 100644 --- a/src/DHTMessageFactoryImpl.cc +++ b/src/DHTMessageFactoryImpl.cc @@ -57,7 +57,7 @@ #include "DHTMessageCallback.h" #include "bittorrent_helper.h" #include "BtRuntime.h" -#include "Util.h" +#include "util.h" #include "Peer.h" #include "Logger.h" #include "StringFormat.h" diff --git a/src/DHTMessageReceiver.cc b/src/DHTMessageReceiver.cc index 4a7b1180..9146e165 100644 --- a/src/DHTMessageReceiver.cc +++ b/src/DHTMessageReceiver.cc @@ -49,7 +49,7 @@ #include "DlAbortEx.h" #include "LogFactory.h" #include "Logger.h" -#include "Util.h" +#include "util.h" #include "bencode.h" namespace aria2 { diff --git a/src/DHTMessageTracker.cc b/src/DHTMessageTracker.cc index af994e50..e3fc44a6 100644 --- a/src/DHTMessageTracker.cc +++ b/src/DHTMessageTracker.cc @@ -42,7 +42,7 @@ #include "DHTNode.h" #include "DHTRoutingTable.h" #include "DHTMessageFactory.h" -#include "Util.h" +#include "util.h" #include "LogFactory.h" #include "Logger.h" #include "DlAbortEx.h" diff --git a/src/DHTMessageTrackerEntry.cc b/src/DHTMessageTrackerEntry.cc index 6267370b..1ff741c7 100644 --- a/src/DHTMessageTrackerEntry.cc +++ b/src/DHTMessageTrackerEntry.cc @@ -37,7 +37,7 @@ #include "DHTMessage.h" #include "DHTMessageCallback.h" #include "DHTConstants.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/DHTNode.cc b/src/DHTNode.cc index ca33f7ea..82beff41 100644 --- a/src/DHTNode.cc +++ b/src/DHTNode.cc @@ -36,7 +36,7 @@ #include -#include "Util.h" +#include "util.h" #include "a2functional.h" #include "bittorrent_helper.h" diff --git a/src/DHTNodeLookupTask.cc b/src/DHTNodeLookupTask.cc index 6a94322d..b1cc73ef 100644 --- a/src/DHTNodeLookupTask.cc +++ b/src/DHTNodeLookupTask.cc @@ -38,7 +38,7 @@ #include "DHTNode.h" #include "DHTNodeLookupEntry.h" #include "LogFactory.h" -#include "Util.h" +#include "util.h" #include namespace aria2 { diff --git a/src/DHTPeerAnnounceStorage.cc b/src/DHTPeerAnnounceStorage.cc index 764f0156..6229e703 100644 --- a/src/DHTPeerAnnounceStorage.cc +++ b/src/DHTPeerAnnounceStorage.cc @@ -46,7 +46,7 @@ #include "DHTTask.h" #include "LogFactory.h" #include "Logger.h" -#include "Util.h" +#include "util.h" #include "a2functional.h" namespace aria2 { diff --git a/src/DHTPeerLookupTask.cc b/src/DHTPeerLookupTask.cc index fc74f898..76fd5f44 100644 --- a/src/DHTPeerLookupTask.cc +++ b/src/DHTPeerLookupTask.cc @@ -43,7 +43,7 @@ #include "DHTMessageCallback.h" #include "PeerStorage.h" #include "BtRuntime.h" -#include "Util.h" +#include "util.h" #include "DHTBucket.h" #include "bittorrent_helper.h" diff --git a/src/DHTQueryMessage.cc b/src/DHTQueryMessage.cc index b0424294..71166005 100644 --- a/src/DHTQueryMessage.cc +++ b/src/DHTQueryMessage.cc @@ -34,7 +34,7 @@ /* copyright --> */ #include "DHTQueryMessage.h" #include "DHTNode.h" -#include "Util.h" +#include "util.h" #include "bencode.h" #include "a2functional.h" diff --git a/src/DHTResponseMessage.cc b/src/DHTResponseMessage.cc index 7180bc3f..92768e4a 100644 --- a/src/DHTResponseMessage.cc +++ b/src/DHTResponseMessage.cc @@ -34,7 +34,7 @@ /* copyright --> */ #include "DHTResponseMessage.h" #include "DHTNode.h" -#include "Util.h" +#include "util.h" #include "bencode.h" #include "a2functional.h" diff --git a/src/DHTRoutingTable.cc b/src/DHTRoutingTable.cc index f1e50e6e..d4d1defc 100644 --- a/src/DHTRoutingTable.cc +++ b/src/DHTRoutingTable.cc @@ -42,7 +42,7 @@ #include "DHTTaskQueue.h" #include "DHTTaskFactory.h" #include "DHTTask.h" -#include "Util.h" +#include "util.h" #include "LogFactory.h" #include "Logger.h" diff --git a/src/DHTRoutingTableDeserializer.cc b/src/DHTRoutingTableDeserializer.cc index eae6d5d4..65059750 100644 --- a/src/DHTRoutingTableDeserializer.cc +++ b/src/DHTRoutingTableDeserializer.cc @@ -47,7 +47,7 @@ #include "Logger.h" #include "a2netcompat.h" #include "StringFormat.h" -#include "Util.h" +#include "util.h" #include "array_fun.h" namespace aria2 { diff --git a/src/DHTRoutingTableSerializer.cc b/src/DHTRoutingTableSerializer.cc index 763e3c61..f20485cb 100644 --- a/src/DHTRoutingTableSerializer.cc +++ b/src/DHTRoutingTableSerializer.cc @@ -45,7 +45,7 @@ #include "Logger.h" #include "a2netcompat.h" #include "StringFormat.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/DHTSetup.cc b/src/DHTSetup.cc index 4bb9cdad..1cf421df 100644 --- a/src/DHTSetup.cc +++ b/src/DHTSetup.cc @@ -39,7 +39,7 @@ #include "LogFactory.h" #include "Logger.h" -#include "Util.h" +#include "util.h" #include "File.h" #include "DHTNode.h" #include "DHTConnectionImpl.h" diff --git a/src/DHTTokenTracker.cc b/src/DHTTokenTracker.cc index 852775cf..54cc5c32 100644 --- a/src/DHTTokenTracker.cc +++ b/src/DHTTokenTracker.cc @@ -36,7 +36,7 @@ #include -#include "Util.h" +#include "util.h" #include "bittorrent_helper.h" #include "DlAbortEx.h" #include "DHTConstants.h" diff --git a/src/DHTUnknownMessage.cc b/src/DHTUnknownMessage.cc index 931111f9..55f074e4 100644 --- a/src/DHTUnknownMessage.cc +++ b/src/DHTUnknownMessage.cc @@ -38,7 +38,7 @@ #include #include "DHTNode.h" -#include "Util.h" +#include "util.h" #include "a2functional.h" namespace aria2 { diff --git a/src/DefaultBtAnnounce.cc b/src/DefaultBtAnnounce.cc index 99b686f9..483986cd 100644 --- a/src/DefaultBtAnnounce.cc +++ b/src/DefaultBtAnnounce.cc @@ -36,7 +36,7 @@ #include "LogFactory.h" #include "Logger.h" #include "PeerListProcessor.h" -#include "Util.h" +#include "util.h" #include "prefs.h" #include "DlAbortEx.h" #include "message.h" diff --git a/src/DefaultBtInteractive.cc b/src/DefaultBtInteractive.cc index f5b88d20..9b6147ee 100644 --- a/src/DefaultBtInteractive.cc +++ b/src/DefaultBtInteractive.cc @@ -39,7 +39,7 @@ #include "prefs.h" #include "message.h" #include "BtHandshakeMessage.h" -#include "Util.h" +#include "util.h" #include "BtKeepAliveMessage.h" #include "BtChokeMessage.h" #include "BtUnchokeMessage.h" diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index 6d80f914..1636caee 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -49,7 +49,7 @@ #include "DlAbortEx.h" #include "message.h" #include "File.h" -#include "Util.h" +#include "util.h" #include "a2io.h" #include "DownloadFailureException.h" #include "StringFormat.h" diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index a9edf5ca..9e7e816f 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -52,7 +52,7 @@ #include "DefaultDiskWriterFactory.h" #include "FileEntry.h" #include "DlAbortEx.h" -#include "Util.h" +#include "util.h" #include "a2functional.h" #include "Option.h" #include "StringFormat.h" diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index fe8a3f14..44c2157c 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -51,7 +51,7 @@ #include "DiskAdaptor.h" #include "DownloadContext.h" #include "Option.h" -#include "Util.h" +#include "util.h" #include "Socket.h" #include "message.h" #include "prefs.h" diff --git a/src/DownloadEngine.cc b/src/DownloadEngine.cc index 03a51844..800672ad 100644 --- a/src/DownloadEngine.cc +++ b/src/DownloadEngine.cc @@ -51,7 +51,7 @@ #include "TimeA2.h" #include "a2time.h" #include "Socket.h" -#include "Util.h" +#include "util.h" #include "a2functional.h" #include "DlAbortEx.h" #include "ServerStatMan.h" diff --git a/src/ExpatMetalinkProcessor.cc b/src/ExpatMetalinkProcessor.cc index 70f681df..a1918b92 100644 --- a/src/ExpatMetalinkProcessor.cc +++ b/src/ExpatMetalinkProcessor.cc @@ -37,7 +37,7 @@ #include "MetalinkParserStateMachine.h" #include "Metalinker.h" #include "MetalinkEntry.h" -#include "Util.h" +#include "util.h" #include "message.h" #include "DlAbortEx.h" diff --git a/src/ExpatXmlRpcRequestProcessor.cc b/src/ExpatXmlRpcRequestProcessor.cc index 60597fdb..46d8b4b3 100644 --- a/src/ExpatXmlRpcRequestProcessor.cc +++ b/src/ExpatXmlRpcRequestProcessor.cc @@ -39,7 +39,7 @@ #include #include "XmlRpcRequestParserStateMachine.h" -#include "Util.h" +#include "util.h" #include "DlAbortEx.h" #include "message.h" diff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc index 6a67b886..c3a94931 100644 --- a/src/FeatureConfig.cc +++ b/src/FeatureConfig.cc @@ -37,7 +37,7 @@ #include #include "array_fun.h" -#include "Util.h" +#include "util.h" #include "Request.h" namespace aria2 { diff --git a/src/File.cc b/src/File.cc index 944f2d75..23ab3933 100644 --- a/src/File.cc +++ b/src/File.cc @@ -43,7 +43,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "A2STR.h" #include "array_fun.h" diff --git a/src/FileAllocationCommand.cc b/src/FileAllocationCommand.cc index dfa669f3..993c4f0b 100644 --- a/src/FileAllocationCommand.cc +++ b/src/FileAllocationCommand.cc @@ -40,7 +40,7 @@ #include "Logger.h" #include "message.h" #include "prefs.h" -#include "Util.h" +#include "util.h" #include "DownloadEngine.h" #include "DownloadContext.h" diff --git a/src/FileEntry.cc b/src/FileEntry.cc index ba092b34..be57587d 100644 --- a/src/FileEntry.cc +++ b/src/FileEntry.cc @@ -37,7 +37,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "URISelector.h" #include "LogFactory.h" diff --git a/src/FixedWidthNumberDecorator.h b/src/FixedWidthNumberDecorator.h index cdcce232..6d3dcc45 100644 --- a/src/FixedWidthNumberDecorator.h +++ b/src/FixedWidthNumberDecorator.h @@ -36,7 +36,7 @@ #define _D_FIXED_WIDTH_NUMBER_DECORATOR_H_ #include "NumberDecorator.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index 3b82c562..1bcc837e 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -41,7 +41,7 @@ #include "Request.h" #include "Segment.h" #include "Option.h" -#include "Util.h" +#include "util.h" #include "message.h" #include "prefs.h" #include "LogFactory.h" diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index 2c7bc051..ce06d639 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -49,7 +49,7 @@ #include "DlAbortEx.h" #include "message.h" #include "prefs.h" -#include "Util.h" +#include "util.h" #include "Option.h" #include "Logger.h" #include "Segment.h" diff --git a/src/HandshakeExtensionMessage.cc b/src/HandshakeExtensionMessage.cc index 6573b2a2..5ce2bd7f 100644 --- a/src/HandshakeExtensionMessage.cc +++ b/src/HandshakeExtensionMessage.cc @@ -34,7 +34,7 @@ /* copyright --> */ #include "HandshakeExtensionMessage.h" #include "Peer.h" -#include "Util.h" +#include "util.h" #include "DlAbortEx.h" #include "LogFactory.h" #include "Logger.h" diff --git a/src/HttpConnection.cc b/src/HttpConnection.cc index 19f3583f..4d2fb3a0 100644 --- a/src/HttpConnection.cc +++ b/src/HttpConnection.cc @@ -36,7 +36,7 @@ #include -#include "Util.h" +#include "util.h" #include "message.h" #include "prefs.h" #include "LogFactory.h" diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index ba8a9234..e70db2cc 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -37,7 +37,7 @@ #include #include "Range.h" -#include "Util.h" +#include "util.h" #include "A2STR.h" namespace aria2 { diff --git a/src/HttpHeaderProcessor.cc b/src/HttpHeaderProcessor.cc index 51fe501b..53d036bd 100644 --- a/src/HttpHeaderProcessor.cc +++ b/src/HttpHeaderProcessor.cc @@ -39,7 +39,7 @@ #include "HttpHeader.h" #include "message.h" -#include "Util.h" +#include "util.h" #include "DlRetryEx.h" #include "DlAbortEx.h" #include "A2STR.h" diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index d4dbad6f..84ad260d 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -42,7 +42,7 @@ #include "Range.h" #include "CookieStorage.h" #include "Option.h" -#include "Util.h" +#include "util.h" #include "Base64.h" #include "prefs.h" #include "AuthConfigFactory.h" diff --git a/src/HttpRequestCommand.cc b/src/HttpRequestCommand.cc index 9ce7e5a9..d4bea72c 100644 --- a/src/HttpRequestCommand.cc +++ b/src/HttpRequestCommand.cc @@ -48,7 +48,7 @@ #include "Socket.h" #include "prefs.h" #include "a2functional.h" -#include "Util.h" +#include "util.h" #include "CookieStorage.h" #include "AuthConfigFactory.h" #include "AuthConfig.h" diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc index fce66f7e..f56abdd1 100644 --- a/src/HttpResponse.cc +++ b/src/HttpResponse.cc @@ -43,7 +43,7 @@ #include "Range.h" #include "LogFactory.h" #include "Logger.h" -#include "Util.h" +#include "util.h" #include "message.h" #include "DlAbortEx.h" #include "DlRetryEx.h" diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index 682f0764..101b58c1 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -50,7 +50,7 @@ #include "DefaultBtProgressInfoFile.h" #include "DownloadFailureException.h" #include "DlAbortEx.h" -#include "Util.h" +#include "util.h" #include "File.h" #include "Option.h" #include "Logger.h" diff --git a/src/HttpServer.cc b/src/HttpServer.cc index ec39253f..9483196c 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -41,7 +41,7 @@ #include "HttpHeaderProcessor.h" #include "DlAbortEx.h" #include "message.h" -#include "Util.h" +#include "util.h" #include "LogFactory.h" #include "Logger.h" #include "Base64.h" diff --git a/src/HttpServerCommand.cc b/src/HttpServerCommand.cc index aa69ea13..b6c20754 100644 --- a/src/HttpServerCommand.cc +++ b/src/HttpServerCommand.cc @@ -45,7 +45,7 @@ #include "RecoverableException.h" #include "prefs.h" #include "Option.h" -#include "Util.h" +#include "util.h" #include "DownloadContext.h" namespace aria2 { diff --git a/src/HttpSkipResponseCommand.cc b/src/HttpSkipResponseCommand.cc index 31322c1b..09a874a3 100644 --- a/src/HttpSkipResponseCommand.cc +++ b/src/HttpSkipResponseCommand.cc @@ -44,7 +44,7 @@ #include "Logger.h" #include "HttpRequest.h" #include "Segment.h" -#include "Util.h" +#include "util.h" #include "StringFormat.h" #include "DlAbortEx.h" #include "HttpHeader.h" diff --git a/src/IndexBtMessage.cc b/src/IndexBtMessage.cc index 589248be..576db3a0 100644 --- a/src/IndexBtMessage.cc +++ b/src/IndexBtMessage.cc @@ -33,7 +33,7 @@ */ /* copyright --> */ #include "IndexBtMessage.h" -#include "Util.h" +#include "util.h" #include "a2functional.h" #include "bittorrent_helper.h" diff --git a/src/IteratableChecksumValidator.cc b/src/IteratableChecksumValidator.cc index 5d59ab3f..799b7ad2 100644 --- a/src/IteratableChecksumValidator.cc +++ b/src/IteratableChecksumValidator.cc @@ -36,7 +36,7 @@ #include -#include "Util.h" +#include "util.h" #include "message.h" #include "PieceStorage.h" #include "messageDigest.h" diff --git a/src/IteratableChunkChecksumValidator.cc b/src/IteratableChunkChecksumValidator.cc index 98b1719e..dc8081e0 100644 --- a/src/IteratableChunkChecksumValidator.cc +++ b/src/IteratableChunkChecksumValidator.cc @@ -38,7 +38,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "message.h" #include "MessageDigestHelper.h" #include "DiskAdaptor.h" diff --git a/src/MSEHandshake.cc b/src/MSEHandshake.cc index 0e1f0c74..0f293ae0 100644 --- a/src/MSEHandshake.cc +++ b/src/MSEHandshake.cc @@ -49,7 +49,7 @@ #include "ARC4Decryptor.h" #include "MessageDigestHelper.h" #include "SimpleRandomizer.h" -#include "Util.h" +#include "util.h" #include "DownloadContext.h" #include "prefs.h" #include "Option.h" diff --git a/src/Makefile.am b/src/Makefile.am index 36fac928..a3ea139e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,7 +30,7 @@ SRCS = Socket.h\ GrowSegment.cc GrowSegment.h\ PiecedSegment.cc PiecedSegment.h\ SegmentMan.cc SegmentMan.h\ - Util.cc Util.h\ + util.cc util.h\ Request.cc Request.h\ common.h\ message.h\ diff --git a/src/Makefile.in b/src/Makefile.in index ad582868..d21dacc6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -312,7 +312,7 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \ FtpTunnelResponseCommand.h SleepCommand.cc SleepCommand.h \ DownloadEngine.cc DownloadEngine.h Segment.h GrowSegment.cc \ GrowSegment.h PiecedSegment.cc PiecedSegment.h SegmentMan.cc \ - SegmentMan.h Util.cc Util.h Request.cc Request.h common.h \ + SegmentMan.h util.cc util.h Request.cc Request.h common.h \ message.h Exception.cc Exception.h FatalException.h \ RecoverableException.h DlAbortEx.h DlRetryEx.h \ DownloadFailureException.h Logger.cc Logger.h SimpleLogger.cc \ @@ -739,7 +739,7 @@ am__objects_27 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \ FtpTunnelRequestCommand.$(OBJEXT) \ FtpTunnelResponseCommand.$(OBJEXT) SleepCommand.$(OBJEXT) \ DownloadEngine.$(OBJEXT) GrowSegment.$(OBJEXT) \ - PiecedSegment.$(OBJEXT) SegmentMan.$(OBJEXT) Util.$(OBJEXT) \ + PiecedSegment.$(OBJEXT) SegmentMan.$(OBJEXT) util.$(OBJEXT) \ Request.$(OBJEXT) Exception.$(OBJEXT) Logger.$(OBJEXT) \ SimpleLogger.$(OBJEXT) AbstractDiskWriter.$(OBJEXT) \ DefaultDiskWriter.$(OBJEXT) DefaultDiskWriterFactory.$(OBJEXT) \ @@ -1038,7 +1038,7 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \ FtpTunnelResponseCommand.h SleepCommand.cc SleepCommand.h \ DownloadEngine.cc DownloadEngine.h Segment.h GrowSegment.cc \ GrowSegment.h PiecedSegment.cc PiecedSegment.h SegmentMan.cc \ - SegmentMan.h Util.cc Util.h Request.cc Request.h common.h \ + SegmentMan.h util.cc util.h Request.cc Request.h common.h \ message.h Exception.cc Exception.h FatalException.h \ RecoverableException.h DlAbortEx.h DlRetryEx.h \ DownloadFailureException.h Logger.cc Logger.h SimpleLogger.cc \ @@ -1514,7 +1514,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UTPexExtensionMessage.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnknownLengthPieceStorage.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UriListParser.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XML2SAXMetalinkProcessor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xml2XmlRpcRequestProcessor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XmlRpcElements.Po@am__quote@ @@ -1544,6 +1543,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prefs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strptime.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timegm.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version_usage.Po@am__quote@ .c.o: diff --git a/src/MessageDigestHelper.cc b/src/MessageDigestHelper.cc index c5a71307..93917f9b 100644 --- a/src/MessageDigestHelper.cc +++ b/src/MessageDigestHelper.cc @@ -37,7 +37,7 @@ #include "DlAbortEx.h" #include "message.h" #include "DefaultDiskWriter.h" -#include "Util.h" +#include "util.h" #include "StringFormat.h" #include #include diff --git a/src/Metalink2RequestGroup.cc b/src/Metalink2RequestGroup.cc index c70f01e9..8e74871c 100644 --- a/src/Metalink2RequestGroup.cc +++ b/src/Metalink2RequestGroup.cc @@ -41,7 +41,7 @@ #include "LogFactory.h" #include "Logger.h" #include "prefs.h" -#include "Util.h" +#include "util.h" #include "message.h" #include "DownloadContext.h" #include "MetalinkHelper.h" diff --git a/src/MetalinkEntry.cc b/src/MetalinkEntry.cc index 8f1d1eaa..af8dfb0a 100644 --- a/src/MetalinkEntry.cc +++ b/src/MetalinkEntry.cc @@ -38,7 +38,7 @@ #include "MetalinkResource.h" #include "FileEntry.h" -#include "Util.h" +#include "util.h" #include "a2functional.h" #ifdef ENABLE_MESSAGE_DIGEST # include "Checksum.h" diff --git a/src/MetalinkParserController.cc b/src/MetalinkParserController.cc index d6cfc923..5d154c34 100644 --- a/src/MetalinkParserController.cc +++ b/src/MetalinkParserController.cc @@ -49,7 +49,7 @@ # include "messageDigest.h" #endif // ENABLE_MESSAGE_DIGEST #include "Signature.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/MetalinkParserStateImpl.cc b/src/MetalinkParserStateImpl.cc index 14239381..27d0ff5c 100644 --- a/src/MetalinkParserStateImpl.cc +++ b/src/MetalinkParserStateImpl.cc @@ -35,7 +35,7 @@ #include "MetalinkParserStateImpl.h" #include "MetalinkParserStateMachine.h" #include "RecoverableException.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/MultiDiskAdaptor.cc b/src/MultiDiskAdaptor.cc index 2d0d1743..1f6f41e4 100644 --- a/src/MultiDiskAdaptor.cc +++ b/src/MultiDiskAdaptor.cc @@ -40,7 +40,7 @@ #include "DefaultDiskWriter.h" #include "message.h" -#include "Util.h" +#include "util.h" #include "FileEntry.h" #include "MultiFileAllocationIterator.h" #include "DefaultDiskWriterFactory.h" diff --git a/src/MultiUrlRequestInfo.cc b/src/MultiUrlRequestInfo.cc index 20318146..d1c531a7 100644 --- a/src/MultiUrlRequestInfo.cc +++ b/src/MultiUrlRequestInfo.cc @@ -47,7 +47,7 @@ #include "DownloadEngineFactory.h" #include "RecoverableException.h" #include "message.h" -#include "Util.h" +#include "util.h" #include "Option.h" #include "StatCalc.h" #include "CookieStorage.h" diff --git a/src/NameMatchOptionHandler.h b/src/NameMatchOptionHandler.h index c34a8279..cb68bab6 100644 --- a/src/NameMatchOptionHandler.h +++ b/src/NameMatchOptionHandler.h @@ -44,7 +44,7 @@ #include #include "A2STR.h" -#include "Util.h" +#include "util.h" #include "OptionHandlerException.h" #define NO_DESCRIPTION A2STR::NIL diff --git a/src/NameResolver.cc b/src/NameResolver.cc index 596cfd58..1bb28a80 100644 --- a/src/NameResolver.cc +++ b/src/NameResolver.cc @@ -36,7 +36,7 @@ #include "DlAbortEx.h" #include "message.h" #include "StringFormat.h" -#include "Util.h" +#include "util.h" #include namespace aria2 { diff --git a/src/Netrc.cc b/src/Netrc.cc index cbdffac8..cb60e977 100644 --- a/src/Netrc.cc +++ b/src/Netrc.cc @@ -41,7 +41,7 @@ #include "DlAbortEx.h" #include "StringFormat.h" #include "A2STR.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/NsCookieParser.cc b/src/NsCookieParser.cc index b5ec205c..be60e4e6 100644 --- a/src/NsCookieParser.cc +++ b/src/NsCookieParser.cc @@ -37,7 +37,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "A2STR.h" #include "DlAbortEx.h" #include "StringFormat.h" diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index af4a48f0..6a695ef9 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -38,7 +38,7 @@ #include "array_fun.h" #include "usage_text.h" #include "A2STR.h" -#include "Util.h" +#include "util.h" #include "help_tags.h" #include "StringFormat.h" #include "File.h" diff --git a/src/OptionHandlerImpl.h b/src/OptionHandlerImpl.h index ae3194b2..30b75d21 100644 --- a/src/OptionHandlerImpl.h +++ b/src/OptionHandlerImpl.h @@ -45,7 +45,7 @@ #include #include "NameMatchOptionHandler.h" -#include "Util.h" +#include "util.h" #include "DlAbortEx.h" #include "prefs.h" #include "Option.h" diff --git a/src/OptionParser.cc b/src/OptionParser.cc index 275944c4..4d208803 100644 --- a/src/OptionParser.cc +++ b/src/OptionParser.cc @@ -41,7 +41,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "OptionHandlerImpl.h" #include "Option.h" #include "A2STR.h" diff --git a/src/ParameterizedStringParser.cc b/src/ParameterizedStringParser.cc index 3752f1c6..dc6d750c 100644 --- a/src/ParameterizedStringParser.cc +++ b/src/ParameterizedStringParser.cc @@ -37,7 +37,7 @@ #include #include "DlAbortEx.h" -#include "Util.h" +#include "util.h" #include "PStringSegment.h" #include "PStringSelect.h" #include "PStringNumLoop.h" diff --git a/src/Peer.cc b/src/Peer.cc index eebe23ae..16d694a6 100644 --- a/src/Peer.cc +++ b/src/Peer.cc @@ -37,7 +37,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "a2functional.h" #include "PeerSessionResource.h" #ifdef ENABLE_MESSAGE_DIGEST diff --git a/src/PeerReceiveHandshakeCommand.cc b/src/PeerReceiveHandshakeCommand.cc index 69ab8c37..8052dda5 100644 --- a/src/PeerReceiveHandshakeCommand.cc +++ b/src/PeerReceiveHandshakeCommand.cc @@ -36,7 +36,7 @@ #include "PeerConnection.h" #include "DownloadEngine.h" #include "BtHandshakeMessage.h" -#include "Util.h" +#include "util.h" #include "DownloadContext.h" #include "DlAbortEx.h" #include "PeerInteractionCommand.h" diff --git a/src/Piece.cc b/src/Piece.cc index 72d25d7d..fdcd51c0 100644 --- a/src/Piece.cc +++ b/src/Piece.cc @@ -33,11 +33,11 @@ */ /* copyright --> */ #include "Piece.h" -#include "Util.h" +#include "util.h" #include "BitfieldManFactory.h" #include "BitfieldMan.h" #include "A2STR.h" -#include "Util.h" +#include "util.h" #include "a2functional.h" #ifdef ENABLE_MESSAGE_DIGEST # include "messageDigest.h" diff --git a/src/RangeBtMessage.cc b/src/RangeBtMessage.cc index b060fbd1..dd54de32 100644 --- a/src/RangeBtMessage.cc +++ b/src/RangeBtMessage.cc @@ -33,7 +33,7 @@ */ /* copyright --> */ #include "RangeBtMessage.h" -#include "Util.h" +#include "util.h" #include "a2functional.h" #include "bittorrent_helper.h" diff --git a/src/Request.cc b/src/Request.cc index 8341e4cf..a6fa8a1e 100644 --- a/src/Request.cc +++ b/src/Request.cc @@ -36,7 +36,7 @@ #include -#include "Util.h" +#include "util.h" #include "FeatureConfig.h" #include "RecoverableException.h" #include "StringFormat.h" diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 7961b2bd..b16b9989 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -47,7 +47,7 @@ #include "CreateRequestCommand.h" #include "File.h" #include "message.h" -#include "Util.h" +#include "util.h" #include "LogFactory.h" #include "Logger.h" #include "DiskAdaptor.h" diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index ba88d7e4..e55eef7a 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -63,7 +63,7 @@ #include "Option.h" #include "prefs.h" #include "File.h" -#include "Util.h" +#include "util.h" #include "Command.h" #include "FileEntry.h" diff --git a/src/RequestSlot.cc b/src/RequestSlot.cc index 01f83d70..e1838a35 100644 --- a/src/RequestSlot.cc +++ b/src/RequestSlot.cc @@ -33,7 +33,7 @@ */ /* copyright --> */ #include "RequestSlot.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/SegmentMan.cc b/src/SegmentMan.cc index 3b383588..0d157838 100644 --- a/src/SegmentMan.cc +++ b/src/SegmentMan.cc @@ -38,7 +38,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "message.h" #include "prefs.h" #include "PiecedSegment.h" diff --git a/src/ServerStatMan.cc b/src/ServerStatMan.cc index efb30757..e1e12a8b 100644 --- a/src/ServerStatMan.cc +++ b/src/ServerStatMan.cc @@ -41,7 +41,7 @@ #include #include "ServerStat.h" -#include "Util.h" +#include "util.h" #include "RecoverableException.h" namespace aria2 { diff --git a/src/SimpleLogger.cc b/src/SimpleLogger.cc index 2baeaa44..d9cf1fa5 100644 --- a/src/SimpleLogger.cc +++ b/src/SimpleLogger.cc @@ -36,7 +36,7 @@ #include -#include "Util.h" +#include "util.h" #include "a2time.h" #include "A2STR.h" #include "StringFormat.h" diff --git a/src/SingleFileAllocationIterator.cc b/src/SingleFileAllocationIterator.cc index 52b8b382..cbf6d214 100644 --- a/src/SingleFileAllocationIterator.cc +++ b/src/SingleFileAllocationIterator.cc @@ -34,7 +34,7 @@ /* copyright --> */ #include "SingleFileAllocationIterator.h" #include "BinaryStream.h" -#include "Util.h" +#include "util.h" #include "a2io.h" #include #include diff --git a/src/SocketCore.cc b/src/SocketCore.cc index 986c256b..423d5efd 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -48,7 +48,7 @@ #include "DlRetryEx.h" #include "DlAbortEx.h" #include "StringFormat.h" -#include "Util.h" +#include "util.h" #include "TimeA2.h" #include "a2functional.h" #ifdef ENABLE_SSL diff --git a/src/Sqlite3MozCookieParser.cc b/src/Sqlite3MozCookieParser.cc index 497a4066..d17a3a5f 100644 --- a/src/Sqlite3MozCookieParser.cc +++ b/src/Sqlite3MozCookieParser.cc @@ -39,7 +39,7 @@ #include #include "DlAbortEx.h" -#include "Util.h" +#include "util.h" #include "StringFormat.h" #include "A2STR.h" #ifndef HAVE_SQLITE3_OPEN_V2 diff --git a/src/TimeA2.cc b/src/TimeA2.cc index 05705305..955cb07c 100644 --- a/src/TimeA2.cc +++ b/src/TimeA2.cc @@ -37,7 +37,7 @@ #include -#include "Util.h" +#include "util.h" #include "array_fun.h" namespace aria2 { diff --git a/src/UTPexExtensionMessage.cc b/src/UTPexExtensionMessage.cc index 7031a90e..27eb0755 100644 --- a/src/UTPexExtensionMessage.cc +++ b/src/UTPexExtensionMessage.cc @@ -34,7 +34,7 @@ /* copyright --> */ #include "UTPexExtensionMessage.h" #include "Peer.h" -#include "Util.h" +#include "util.h" #include "bittorrent_helper.h" #include "PeerStorage.h" #include "PeerListProcessor.h" diff --git a/src/UriListParser.cc b/src/UriListParser.cc index 1a6ed3dc..f2c62b60 100644 --- a/src/UriListParser.cc +++ b/src/UriListParser.cc @@ -37,7 +37,7 @@ #include #include -#include "Util.h" +#include "util.h" #include "Option.h" #include "OptionHandlerFactory.h" #include "OptionHandler.h" diff --git a/src/Util.cc b/src/Util.cc deleted file mode 100644 index 77532c61..00000000 --- a/src/Util.cc +++ /dev/null @@ -1,845 +0,0 @@ -/* */ -#include "Util.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef HAVE_SLEEP -# ifdef HAVE_WINSOCK_H -# define WIN32_LEAN_AND_MEAN -# include -# endif // HAVE_WINSOCK_H -#endif // HAVE_SLEEP - -#ifdef HAVE_LIBGCRYPT -# include -#elif HAVE_LIBSSL -# include -# include "SimpleRandomizer.h" -#endif // HAVE_LIBSSL - -#include "File.h" -#include "message.h" -#include "Randomizer.h" -#include "a2netcompat.h" -#include "DlAbortEx.h" -#include "BitfieldMan.h" -#include "DefaultDiskWriter.h" -#include "FatalException.h" -#include "FileEntry.h" -#include "StringFormat.h" -#include "A2STR.h" -#include "array_fun.h" -#include "a2functional.h" - -// For libc6 which doesn't define ULLONG_MAX properly because of broken limits.h -#ifndef ULLONG_MAX -# define ULLONG_MAX 18446744073709551615ULL -#endif // ULLONG_MAX - -namespace aria2 { - -namespace util { - -const std::string DEFAULT_TRIM_CHARSET("\r\n\t "); - -std::string trim(const std::string& src, const std::string& trimCharset) -{ - std::string temp(src); - trimSelf(temp, trimCharset); - return temp; -} - -void trimSelf(std::string& str, const std::string& trimCharset) -{ - std::string::size_type first = str.find_first_not_of(trimCharset); - if(first == std::string::npos) { - str.clear(); - } else { - std::string::size_type last = str.find_last_not_of(trimCharset)+1; - str.erase(last); - str.erase(0, first); - } -} - -void split(std::pair& hp, const std::string& src, char delim) -{ - hp.first = A2STR::NIL; - hp.second = A2STR::NIL; - std::string::size_type p = src.find(delim); - if(p == std::string::npos) { - hp.first = src; - hp.second = A2STR::NIL; - } else { - hp.first = trim(src.substr(0, p)); - hp.second = trim(src.substr(p+1)); - } -} - -std::pair split(const std::string& src, const std::string& delims) -{ - std::pair hp; - hp.first = A2STR::NIL; - hp.second = A2STR::NIL; - std::string::size_type p = src.find_first_of(delims); - if(p == std::string::npos) { - hp.first = src; - hp.second = A2STR::NIL; - } else { - hp.first = trim(src.substr(0, p)); - hp.second = trim(src.substr(p+1)); - } - return hp; -} - -int64_t difftv(struct timeval tv1, struct timeval tv2) { - if((tv1.tv_sec < tv2.tv_sec) || - ((tv1.tv_sec == tv2.tv_sec) && (tv1.tv_usec < tv2.tv_usec))) { - return 0; - } - return ((int64_t)(tv1.tv_sec-tv2.tv_sec)*1000000+ - tv1.tv_usec-tv2.tv_usec); -} - -int32_t difftvsec(struct timeval tv1, struct timeval tv2) { - if(tv1.tv_sec < tv2.tv_sec) { - return 0; - } - return tv1.tv_sec-tv2.tv_sec; -} - -bool startsWith(const std::string& target, const std::string& part) { - if(target.size() < part.size()) { - return false; - } - if(part.empty()) { - return true; - } - if(target.find(part) == 0) { - return true; - } else { - return false; - } -} - -bool endsWith(const std::string& target, const std::string& part) { - if(target.size() < part.size()) { - return false; - } - if(part.empty()) { - return true; - } - if(target.rfind(part) == target.size()-part.size()) { - return true; - } else { - return false; - } -} - -std::string replace(const std::string& target, const std::string& oldstr, const std::string& newstr) { - if(target.empty() || oldstr.empty()) { - return target; - } - std::string result; - std::string::size_type p = 0; - std::string::size_type np = target.find(oldstr); - while(np != std::string::npos) { - result += target.substr(p, np-p); - result += newstr; - p = np+oldstr.size(); - np = target.find(oldstr, p); - } - result += target.substr(p); - - return result; -} - -bool inRFC3986ReservedChars(const char c) -{ - static const char reserved[] = { - ':' , '/' , '?' , '#' , '[' , ']' , '@', - '!' , '$' , '&' , '\'' , '(' , ')', - '*' , '+' , ',' , ';' , '=' }; - return std::find(&reserved[0], &reserved[arrayLength(reserved)], c) != - &reserved[arrayLength(reserved)]; -} - -bool inRFC3986UnreservedChars(const char c) -{ - static const char unreserved[] = { '-', '.', '_', '~' }; - return - // ALPHA - ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || - // DIGIT - ('0' <= c && c <= '9') || - std::find(&unreserved[0], &unreserved[arrayLength(unreserved)], c) != - &unreserved[arrayLength(unreserved)]; -} - -std::string urlencode(const unsigned char* target, size_t len) { - std::string dest; - for(size_t i = 0; i < len; ++i) { - if(!inRFC3986UnreservedChars(target[i])) { - dest.append(StringFormat("%%%02X", target[i]).str()); - } else { - dest += target[i]; - } - } - return dest; -} - -std::string urlencode(const std::string& target) -{ - return urlencode((const unsigned char*)target.c_str(), target.size()); -} - -std::string torrentUrlencode(const unsigned char* target, size_t len) { - std::string dest; - for(size_t i = 0; i < len; ++i) { - if(('0' <= target[i] && target[i] <= '9') || - ('A' <= target[i] && target[i] <= 'Z') || - ('a' <= target[i] && target[i] <= 'z')) { - dest += target[i]; - } else { - dest.append(StringFormat("%%%02X", target[i]).str()); - } - } - return dest; -} - -std::string torrentUrlencode(const std::string& target) -{ - return torrentUrlencode - (reinterpret_cast(target.c_str()), target.size()); -} - -std::string urldecode(const std::string& target) { - std::string result; - for(std::string::const_iterator itr = target.begin(); - itr != target.end(); ++itr) { - if(*itr == '%') { - if(itr+1 != target.end() && itr+2 != target.end() && - isxdigit(*(itr+1)) && isxdigit(*(itr+2))) { - result += parseInt(std::string(itr+1, itr+3), 16); - itr += 2; - } else { - result += *itr; - } - } else { - result += *itr; - } - } - return result; -} - -std::string toHex(const unsigned char* src, size_t len) { - char* temp = new char[len*2+1]; - for(size_t i = 0; i < len; ++i) { - sprintf(temp+i*2, "%02x", src[i]); - } - temp[len*2] = '\0'; - std::string hex = temp; - delete [] temp; - return hex; -} - -std::string toHex(const char* src, size_t len) -{ - return toHex(reinterpret_cast(src), len); -} - -std::string toHex(const std::string& src) -{ - return toHex(reinterpret_cast(src.c_str()), src.size()); -} - -FILE* openFile(const std::string& filename, const std::string& mode) { - FILE* file = fopen(filename.c_str(), mode.c_str()); - return file; -} - -bool isPowerOf(int num, int base) { - if(base <= 0) { return false; } - if(base == 1) { return true; } - - while(num%base == 0) { - num /= base; - if(num == 1) { - return true; - } - } - return false; -} - -std::string secfmt(time_t sec) { - std::string str; - if(sec >= 3600) { - str = itos(sec/3600); - str += "h"; - sec %= 3600; - } - if(sec >= 60) { - int min = sec/60; - if(min < 10) { - str += "0"; - } - str += itos(min); - str += "m"; - sec %= 60; - } - if(sec < 10) { - str += "0"; - } - str += itos(sec); - str += "s"; - return str; -} - -int getNum(const char* buf, int offset, size_t length) { - char* temp = new char[length+1]; - memcpy(temp, buf+offset, length); - temp[length] = '\0'; - int x = strtol(temp, 0, 10); - delete [] temp; - return x; -} - -int32_t parseInt(const std::string& s, int32_t base) -{ - std::string trimed = trim(s); - if(trimed.empty()) { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - "empty string").str()); - } - char* stop; - errno = 0; - long int v = strtol(trimed.c_str(), &stop, base); - if(*stop != '\0') { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); - } else if((((v == LONG_MIN) || (v == LONG_MAX)) && (errno == ERANGE)) || - (v > INT32_MAX) || - (v < INT32_MIN)) { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); - } - return v; -} - -uint32_t parseUInt(const std::string& s, int base) -{ - std::string trimed = trim(s); - if(trimed.empty()) { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - "empty string").str()); - } - // We don't allow negative number. - if(trimed[0] == '-') { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); - } - char* stop; - errno = 0; - unsigned long int v = strtoul(trimed.c_str(), &stop, base); - if(*stop != '\0') { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); - } else if(((v == ULONG_MAX) && (errno == ERANGE)) || (v > UINT32_MAX)) { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); - } - return v; -} - -int64_t parseLLInt(const std::string& s, int32_t base) -{ - std::string trimed = trim(s); - if(trimed.empty()) { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - "empty string").str()); - } - char* stop; - errno = 0; - int64_t v = strtoll(trimed.c_str(), &stop, base); - if(*stop != '\0') { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); - } else if(((v == INT64_MIN) || (v == INT64_MAX)) && (errno == ERANGE)) { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); - } - return v; -} - -uint64_t parseULLInt(const std::string& s, int base) -{ - std::string trimed = trim(s); - if(trimed.empty()) { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - "empty string").str()); - } - // We don't allow negative number. - if(trimed[0] == '-') { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); - } - char* stop; - errno = 0; - uint64_t v = strtoull(trimed.c_str(), &stop, base); - if(*stop != '\0') { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); - } else if((v == ULLONG_MAX) && (errno == ERANGE)) { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); - } - return v; -} - -IntSequence parseIntRange(const std::string& src) -{ - IntSequence::Values values; - std::string temp = src; - while(temp.size()) { - std::pair p = split(temp, ","); - temp = p.second; - if(p.first.empty()) { - continue; - } - if(p.first.find("-") == std::string::npos) { - int32_t v = parseInt(p.first.c_str()); - values.push_back(IntSequence::Value(v, v+1)); - } else { - std::pair vp = split(p.first.c_str(), "-"); - if(vp.first.empty() || vp.second.empty()) { - throw DL_ABORT_EX - (StringFormat(MSG_INCOMPLETE_RANGE, p.first.c_str()).str()); - } - int32_t v1 = parseInt(vp.first.c_str()); - int32_t v2 = parseInt(vp.second.c_str()); - values.push_back(IntSequence::Value(v1, v2+1)); - } - } - return values; -} - -std::string getContentDispositionFilename(const std::string& header) { - static const std::string keyName = "filename="; - std::string::size_type attributesp = header.find(keyName); - if(attributesp == std::string::npos) { - return A2STR::NIL; - } - std::string::size_type filenamesp = attributesp+keyName.size(); - std::string::size_type filenameep; - if(filenamesp == header.size()) { - return A2STR::NIL; - } - - if(header[filenamesp] == '\'' || header[filenamesp] == '"') { - char quoteChar = header[filenamesp]; - filenameep = header.find(quoteChar, filenamesp+1); - } else { - filenameep = header.find(';', filenamesp); - } - if(filenameep == std::string::npos) { - filenameep = header.size(); - } - static const std::string TRIMMED("\r\n '\""); - std::string fn = - File(trim(header.substr - (filenamesp, filenameep-filenamesp), TRIMMED)).getBasename(); - if(fn == ".." || fn == ".") { - return A2STR::NIL; - } else { - return fn; - } -} - -std::string randomAlpha(size_t length, const RandomizerHandle& randomizer) { - static const char *random_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - std::string str; - for(size_t i = 0; i < length; ++i) { - size_t index = randomizer->getRandomNumber(strlen(random_chars)); - str += random_chars[index]; - } - return str; -} - -std::string toUpper(const std::string& src) { - std::string temp = src; - std::transform(temp.begin(), temp.end(), temp.begin(), ::toupper); - return temp; -} - -std::string toLower(const std::string& src) { - std::string temp = src; - std::transform(temp.begin(), temp.end(), temp.begin(), ::tolower); - return temp; -} - -bool isNumbersAndDotsNotation(const std::string& name) { - struct sockaddr_in sockaddr; - if(inet_aton(name.c_str(), &sockaddr.sin_addr)) { - return true; - } else { - return false; - } -} - -void setGlobalSignalHandler(int sig, void (*handler)(int), int flags) { -#ifdef HAVE_SIGACTION - struct sigaction sigact; - sigact.sa_handler = handler; - sigact.sa_flags = flags; - sigemptyset(&sigact.sa_mask); - sigaction(sig, &sigact, NULL); -#else - signal(sig, handler); -#endif // HAVE_SIGACTION -} - -std::string getHomeDir() -{ - const char* p = getenv("HOME"); - if(p) { - return p; - } else { - return A2STR::NIL; - } -} - -int64_t getRealSize(const std::string& sizeWithUnit) -{ - std::string::size_type p = sizeWithUnit.find_first_of("KM"); - std::string size; - int32_t mult = 1; - if(p == std::string::npos) { - size = sizeWithUnit; - } else { - if(sizeWithUnit[p] == 'K') { - mult = 1024; - } else if(sizeWithUnit[p] == 'M') { - mult = 1024*1024; - } - size = sizeWithUnit.substr(0, p); - } - int64_t v = parseLLInt(size); - - if(v < 0) { - throw DL_ABORT_EX - (StringFormat("Negative value detected: %s", sizeWithUnit.c_str()).str()); - } else if(INT64_MAX/mult < v) { - throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - "overflow/underflow").str()); - } - return v*mult; -} - -std::string abbrevSize(int64_t size) -{ - if(size < 1024) { - return itos(size, true); - } - char units[] = { 'K', 'M' }; - size_t numUnit = sizeof(units)/sizeof(char); - size_t i = 0; - int r = size&0x3ff; - size >>= 10; - for(; i < numUnit-1 && size >= 1024; ++i) { - r = size&0x3ff; - size >>= 10; - } - std::string result = itos(size, true); - result += "."; - result += itos(r*10/1024); - result += units[i]; - result += "i"; - return result; -} - -void sleep(long seconds) { -#ifdef HAVE_SLEEP - ::sleep(seconds); -#elif defined(HAVE_USLEEP) - ::usleep(seconds * 1000000); -#elif defined(HAVE_WINSOCK2_H) - ::Sleep(seconds * 1000); -#else -#error no sleep function is available (nanosleep?) -#endif -} - -void usleep(long microseconds) { -#ifdef HAVE_USLEEP - ::usleep(microseconds); -#elif defined(HAVE_WINSOCK2_H) - - LARGE_INTEGER current, freq, end; - - static enum {GET_FREQUENCY, GET_MICROSECONDS, SKIP_MICROSECONDS} state = GET_FREQUENCY; - - if (state == GET_FREQUENCY) { - if (QueryPerformanceFrequency(&freq)) - state = GET_MICROSECONDS; - else - state = SKIP_MICROSECONDS; - } - - long msec = microseconds / 1000; - microseconds %= 1000; - - if (state == GET_MICROSECONDS && microseconds) { - QueryPerformanceCounter(&end); - - end.QuadPart += (freq.QuadPart * microseconds) / 1000000; - - while (QueryPerformanceCounter(¤t) && (current.QuadPart <= end.QuadPart)) - /* noop */ ; - } - - if (msec) - Sleep(msec); -#else - #error no usleep function is available (nanosleep?) -#endif -} - -bool isNumber(const std::string& what) -{ - if(what.empty()) { - return false; - } - for(uint32_t i = 0; i < what.size(); ++i) { - if(!isdigit(what[i])) { - return false; - } - } - return true; -} - -bool isLowercase(const std::string& what) -{ - if(what.empty()) { - return false; - } - for(uint32_t i = 0; i < what.size(); ++i) { - if(!('a' <= what[i] && what[i] <= 'z')) { - return false; - } - } - return true; -} - -bool isUppercase(const std::string& what) -{ - if(what.empty()) { - return false; - } - for(uint32_t i = 0; i < what.size(); ++i) { - if(!('A' <= what[i] && what[i] <= 'Z')) { - return false; - } - } - return true; -} - -unsigned int alphaToNum(const std::string& alphabets) -{ - if(alphabets.empty()) { - return 0; - } - char base; - if(islower(alphabets[0])) { - base = 'a'; - } else { - base = 'A'; - } - uint64_t num = 0; - for(size_t i = 0; i < alphabets.size(); ++i) { - unsigned int v = alphabets[i]-base; - num = num*26+v; - if(num > UINT32_MAX) { - return 0; - } - } - return num; -} - -void mkdirs(const std::string& dirpath) -{ - File dir(dirpath); - if(dir.isDir()) { - // do nothing - } else if(dir.exists()) { - throw DL_ABORT_EX - (StringFormat(EX_MAKE_DIR, dir.getPath().c_str(), - "File already exists.").str()); - } else if(!dir.mkdirs()) { - throw DL_ABORT_EX - (StringFormat(EX_MAKE_DIR, dir.getPath().c_str(), - strerror(errno)).str()); - } -} - -void convertBitfield(BitfieldMan* dest, const BitfieldMan* src) -{ - size_t numBlock = dest->countBlock(); - for(size_t index = 0; index < numBlock; ++index) { - if(src->isBitSetOffsetRange((uint64_t)index*dest->getBlockLength(), - dest->getBlockLength())) { - dest->setBit(index); - } - } -} - -std::string toString(const BinaryStreamHandle& binaryStream) -{ - std::stringstream strm; - char data[2048]; - while(1) { - int32_t dataLength = binaryStream->readData((unsigned char*)data, sizeof(data), strm.tellp()); - strm.write(data, dataLength); - if(dataLength == 0) { - break; - } - } - return strm.str(); -} - -#ifdef HAVE_POSIX_MEMALIGN -/** - * In linux 2.6, alignment and size should be a multiple of 512. - */ -void* allocateAlignedMemory(size_t alignment, size_t size) -{ - void* buffer; - int res; - if((res = posix_memalign(&buffer, alignment, size)) != 0) { - throw FATAL_EXCEPTION - (StringFormat("Error in posix_memalign: %s", strerror(res)).str()); - } - return buffer; -} -#endif // HAVE_POSIX_MEMALIGN - -std::pair -getNumericNameInfo(const struct sockaddr* sockaddr, socklen_t len) -{ - char host[NI_MAXHOST]; - char service[NI_MAXSERV]; - int s = getnameinfo(sockaddr, len, host, NI_MAXHOST, service, NI_MAXSERV, - NI_NUMERICHOST|NI_NUMERICSERV); - if(s != 0) { - throw DL_ABORT_EX(StringFormat("Failed to get hostname and port. cause: %s", - gai_strerror(s)).str()); - } - return std::pair(host, atoi(service)); // TODO -} - -std::string htmlEscape(const std::string& src) -{ - std::string dest; - for(std::string::const_iterator i = src.begin(); i != src.end(); ++i) { - char ch = *i; - if(ch == '<') { - dest += "<"; - } else if(ch == '>') { - dest += ">"; - } else if(ch == '&') { - dest += "&"; - } else if(ch == '\'') { - dest += "'"; - } else if(ch == '"') { - dest += """; - } else { - dest += ch; - } - } - return dest; -} - -std::map::value_type -parseIndexPath(const std::string& line) -{ - std::pair p = split(line, "="); - size_t index = parseUInt(p.first); - if(p.second.empty()) { - throw DL_ABORT_EX(StringFormat("Path with index=%u is empty.", - static_cast(index)).str()); - } - return std::map::value_type(index, p.second); -} - -std::map createIndexPathMap(std::istream& i) -{ - std::map indexPathMap; - std::string line; - while(getline(i, line)) { - indexPathMap.insert(indexPathMap.begin(), parseIndexPath(line)); - } - return indexPathMap; -} - -void generateRandomData(unsigned char* data, size_t length) -{ -#ifdef HAVE_LIBGCRYPT - gcry_randomize(data, length, GCRY_STRONG_RANDOM); -#elif HAVE_LIBSSL - if(RAND_bytes(data, length) != 1) { - for(size_t i = 0; i < length; ++i) { - data[i] = SimpleRandomizer::getInstance()->getRandomNumber(UINT8_MAX+1); - } - } -#else - std::ifstream i("/dev/urandom", std::ios::binary); - i.read(data, length); -#endif // HAVE_LIBSSL -} - -} // namespace util - -} // namespace aria2 diff --git a/src/Util.h b/src/Util.h deleted file mode 100644 index eceb38cb..00000000 --- a/src/Util.h +++ /dev/null @@ -1,327 +0,0 @@ -/* */ -#ifndef _D_UTIL_H_ -#define _D_UTIL_H_ - -#include "common.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "SharedHandle.h" -#include "IntSequence.h" -#include "a2time.h" -#include "a2netcompat.h" -#include "a2functional.h" - -namespace aria2 { - -class Randomizer; -class BitfieldMan; -class BinaryStream; -class FileEntry; - -#define STRTOLL(X) strtoll(X, (char**)0, 10) -#define STRTOULL(X) strtoull(X, (char**)0, 10) - -#define START_INDEX(OFFSET, PIECE_LENGTH) ((OFFSET)/(PIECE_LENGTH)) -#define END_INDEX(OFFSET, LENGTH, PIECE_LENGTH) (((OFFSET)+(LENGTH)-1)/(PIECE_LENGTH)) - -#define DIV_FLOOR(X,Y) ((X)/(Y)+((X)%(Y)? 1:0)) - -#ifdef WORDS_BIGENDIAN -inline uint64_t ntoh64(uint64_t x) { return x; } -inline uint64_t hton64(uint64_t x) { return x; } -#else // !WORDS_BIGENDIAN -inline uint64_t byteswap64(uint64_t x) { - uint64_t v1 = ntohl(x & 0x00000000ffffffff); - uint64_t v2 = ntohl(x >> 32); - return (v1 << 32)|v2; -} -inline uint64_t ntoh64(uint64_t x) { return byteswap64(x); } -inline uint64_t hton64(uint64_t x) { return byteswap64(x); } -#endif // !WORDS_BIGENDIAN - -namespace util { - -void split(std::pair& hp, - const std::string& src, char delim); - -std::pair -split(const std::string& src, const std::string& delims); - -template -std::string uitos(T value, bool comma = false) -{ - std::string str; - if(value == 0) { - str = "0"; - return str; - } - unsigned int count = 0; - while(value) { - ++count; - char digit = value%10+'0'; - str.insert(str.begin(), digit); - value /= 10; - if(comma && count > 3 && count%3 == 1) { - str.insert(str.begin()+1, ','); - } - } - return str; -} - -template -std::string itos(T value, bool comma = false) -{ - bool flag = false; - if(value < 0) { - flag = true; - value = -value; - } - std::string str = uitos(value, comma); - if(flag) { - str.insert(str.begin(), '-'); - } - return str; -} - -/** - * Computes difference in micro-seconds between tv1 and tv2, - * assuming tv1 is newer than tv2. - * If tv1 is older than tv2, then this method returns 0. - */ -int64_t difftv(struct timeval tv1, struct timeval tv2); -int32_t difftvsec(struct timeval tv1, struct timeval tv2); - -extern const std::string DEFAULT_TRIM_CHARSET; - -std::string trim(const std::string& src, - const std::string& trimCharset = DEFAULT_TRIM_CHARSET); - -void trimSelf(std::string& str, - const std::string& trimCharset = DEFAULT_TRIM_CHARSET); - -bool startsWith(const std::string& target, const std::string& part); - -bool endsWith(const std::string& target, const std::string& part); - -std::string replace(const std::string& target, const std::string& oldstr, const std::string& newstr); - -std::string urlencode(const unsigned char* target, size_t len); - -std::string urlencode(const std::string& target); - -bool inRFC3986ReservedChars(const char c); - -bool inRFC3986UnreservedChars(const char c); - -std::string urldecode(const std::string& target); - -std::string torrentUrlencode(const unsigned char* target, size_t len); - -std::string torrentUrlencode(const std::string& target); - -std::string toHex(const unsigned char* src, size_t len); - -std::string toHex(const char* src, size_t len); - -std::string toHex(const std::string& src); - -FILE* openFile(const std::string& filename, const std::string& mode); - -bool isPowerOf(int num, int base); - -std::string secfmt(time_t sec); - -int32_t parseInt(const std::string& s, int32_t base = 10); - -uint32_t parseUInt(const std::string& s, int base = 10); - -int64_t parseLLInt(const std::string& s, int32_t base = 10); - -uint64_t parseULLInt(const std::string& s, int base = 10); - -IntSequence parseIntRange(const std::string& src); - -// this function temporarily put here -std::string getContentDispositionFilename(const std::string& header); - -std::string randomAlpha(size_t length, - const SharedHandle& randomizer); - -std::string toUpper(const std::string& src); - -std::string toLower(const std::string& src); - -bool isNumbersAndDotsNotation(const std::string& name); - -void setGlobalSignalHandler(int signal, void (*handler)(int), int flags); - -std::string getHomeDir(); - -int64_t getRealSize(const std::string& sizeWithUnit); - -std::string abbrevSize(int64_t size); - -template -void toStream -(InputIterator first, InputIterator last, std::ostream& os) -{ - os << _("Files:") << "\n"; - os << "idx|path/length" << "\n"; - os << "===+===========================================================================" << "\n"; - int32_t count = 1; - for(; first != last; ++first, ++count) { - os << std::setw(3) << count << "|" << (*first)->getPath() << "\n"; - os << " |" << util::abbrevSize((*first)->getLength()) << "B (" - << util::uitos((*first)->getLength(), true) << ")\n"; - os << "---+---------------------------------------------------------------------------" << "\n"; - } -} - -void sleep(long seconds); - -void usleep(long microseconds); - -bool isNumber(const std::string& what); - -bool isLowercase(const std::string& what); - -bool isUppercase(const std::string& what); - -/** - * Converts alphabets to unsigned int, assuming alphabets as a base 26 - * integer and 'a' or 'A' is 0. - * This function assumes alphabets includes only a-z. - * Upper case are allowed but all letters must be upper case. - * If overflow occurs, returns 0. - */ -unsigned int alphaToNum(const std::string& alphabets); - -void mkdirs(const std::string& dirpath); - -void convertBitfield(BitfieldMan* dest, const BitfieldMan* src); - -// binaryStream has to be opened before calling this function. -std::string toString(const SharedHandle& binaryStream); - -#ifdef HAVE_POSIX_MEMALIGN -void* allocateAlignedMemory(size_t alignment, size_t size); -#endif // HAVE_POSIX_MEMALIGN - -std::pair -getNumericNameInfo(const struct sockaddr* sockaddr, socklen_t len); - -std::string htmlEscape(const std::string& src); - -// Joins path element specified in [first, last). If ".." is found, -// it eats the previous element if it exists. If "." is found, it -// is just ignored and it is not appeared in the result. -template -std::string joinPath(InputIterator first, InputIterator last) -{ - std::deque elements; - for(;first != last; ++first) { - if(*first == "..") { - if(!elements.empty()) { - elements.pop_back(); - } - } else if(*first == ".") { - // do nothing - } else { - elements.push_back(*first); - } - } - return strjoin(elements.begin(), elements.end(), "/"); -} - -// Parses INDEX=PATH format string. INDEX must be an unsigned -// integer. -std::map::value_type -parseIndexPath(const std::string& line); - -std::map createIndexPathMap(std::istream& i); - -/** - * Take a string src which is a deliminated list and add its elements - * into result. result is stored in out. - */ -template -OutputIterator split(const std::string& src, OutputIterator out, - const std::string& delims, bool doTrim = false) -{ - std::string::size_type p = 0; - while(1) { - std::string::size_type np = src.find_first_of(delims, p); - if(np == std::string::npos) { - std::string term = src.substr(p); - if(doTrim) { - term = util::trim(term); - } - if(!term.empty()) { - *out = term; - ++out; - } - break; - } - std::string term = src.substr(p, np-p); - if(doTrim) { - term = util::trim(term); - } - p = np+1; - if(!term.empty()) { - *out = term; - ++out; - } - } - return out; -} - -void generateRandomData(unsigned char* data, size_t length); - -} // namespace util - -} // namespace aria2 - -#endif // _D_UTIL_H_ diff --git a/src/XML2SAXMetalinkProcessor.cc b/src/XML2SAXMetalinkProcessor.cc index 39061101..15a0e3f9 100644 --- a/src/XML2SAXMetalinkProcessor.cc +++ b/src/XML2SAXMetalinkProcessor.cc @@ -37,7 +37,7 @@ #include "MetalinkParserStateMachine.h" #include "Metalinker.h" #include "MetalinkEntry.h" -#include "Util.h" +#include "util.h" #include "message.h" #include "DlAbortEx.h" diff --git a/src/Xml2XmlRpcRequestProcessor.cc b/src/Xml2XmlRpcRequestProcessor.cc index 0a568606..e88966bc 100644 --- a/src/Xml2XmlRpcRequestProcessor.cc +++ b/src/Xml2XmlRpcRequestProcessor.cc @@ -39,7 +39,7 @@ #include #include "XmlRpcRequestParserStateMachine.h" -#include "Util.h" +#include "util.h" #include "DlAbortEx.h" #include "message.h" diff --git a/src/XmlRpcMethodImpl.cc b/src/XmlRpcMethodImpl.cc index ed97d6e5..9f90d228 100644 --- a/src/XmlRpcMethodImpl.cc +++ b/src/XmlRpcMethodImpl.cc @@ -46,7 +46,7 @@ #include "DownloadEngine.h" #include "RequestGroup.h" #include "download_helper.h" -#include "Util.h" +#include "util.h" #include "RequestGroupMan.h" #include "StringFormat.h" #include "XmlRpcRequest.h" diff --git a/src/XmlRpcRequestParserStateImpl.cc b/src/XmlRpcRequestParserStateImpl.cc index b4c4764a..a18a7e65 100644 --- a/src/XmlRpcRequestParserStateImpl.cc +++ b/src/XmlRpcRequestParserStateImpl.cc @@ -36,7 +36,7 @@ #include "XmlRpcRequestParserStateMachine.h" #include "XmlRpcElements.h" #include "RecoverableException.h" -#include "Util.h" +#include "util.h" #include "Base64.h" namespace aria2 { diff --git a/src/XmlRpcResponse.cc b/src/XmlRpcResponse.cc index bccc95a5..4cc09b21 100644 --- a/src/XmlRpcResponse.cc +++ b/src/XmlRpcResponse.cc @@ -37,7 +37,7 @@ #include #include -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/bitfield.h b/src/bitfield.h index 26f4d024..38d3b0a7 100644 --- a/src/bitfield.h +++ b/src/bitfield.h @@ -40,7 +40,7 @@ #include #include -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/bittorrent_helper.cc b/src/bittorrent_helper.cc index 7b55f12a..60bc11bc 100644 --- a/src/bittorrent_helper.cc +++ b/src/bittorrent_helper.cc @@ -41,7 +41,7 @@ #include "DownloadContext.h" #include "Randomizer.h" #include "bencode.h" -#include "Util.h" +#include "util.h" #include "DlAbortEx.h" #include "message.h" #include "StringFormat.h" diff --git a/src/bittorrent_helper.h b/src/bittorrent_helper.h index c9d64579..bc9c8fe9 100644 --- a/src/bittorrent_helper.h +++ b/src/bittorrent_helper.h @@ -45,7 +45,7 @@ #include "SharedHandle.h" #include "AnnounceTier.h" #include "BDE.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/download_helper.cc b/src/download_helper.cc index 418ea96c..900604ac 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -56,7 +56,7 @@ #include "FileEntry.h" #include "LogFactory.h" #include "File.h" -#include "Util.h" +#include "util.h" #include "array_fun.h" #include "OptionHandler.h" #include "ByteArrayDiskWriter.h" diff --git a/src/main.cc b/src/main.cc index d5b4ab19..62a14e28 100644 --- a/src/main.cc +++ b/src/main.cc @@ -46,7 +46,7 @@ #include "SharedHandle.h" #include "LogFactory.h" #include "Logger.h" -#include "Util.h" +#include "util.h" #include "BitfieldManFactory.h" #include "FeatureConfig.h" #include "MultiUrlRequestInfo.h" diff --git a/src/messageDigest.cc b/src/messageDigest.cc index 1f498edd..06e79704 100644 --- a/src/messageDigest.cc +++ b/src/messageDigest.cc @@ -33,7 +33,7 @@ */ /* copyright --> */ #include "messageDigest.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/src/option_processing.cc b/src/option_processing.cc index 6ae461a6..847b4f55 100644 --- a/src/option_processing.cc +++ b/src/option_processing.cc @@ -45,7 +45,7 @@ #include "OptionParser.h" #include "OptionHandlerFactory.h" #include "OptionHandler.h" -#include "Util.h" +#include "util.h" #include "message.h" #include "Exception.h" #include "a2io.h" diff --git a/src/util.cc b/src/util.cc new file mode 100644 index 00000000..bcaa1a77 --- /dev/null +++ b/src/util.cc @@ -0,0 +1,845 @@ +/* */ +#include "util.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef HAVE_SLEEP +# ifdef HAVE_WINSOCK_H +# define WIN32_LEAN_AND_MEAN +# include +# endif // HAVE_WINSOCK_H +#endif // HAVE_SLEEP + +#ifdef HAVE_LIBGCRYPT +# include +#elif HAVE_LIBSSL +# include +# include "SimpleRandomizer.h" +#endif // HAVE_LIBSSL + +#include "File.h" +#include "message.h" +#include "Randomizer.h" +#include "a2netcompat.h" +#include "DlAbortEx.h" +#include "BitfieldMan.h" +#include "DefaultDiskWriter.h" +#include "FatalException.h" +#include "FileEntry.h" +#include "StringFormat.h" +#include "A2STR.h" +#include "array_fun.h" +#include "a2functional.h" + +// For libc6 which doesn't define ULLONG_MAX properly because of broken limits.h +#ifndef ULLONG_MAX +# define ULLONG_MAX 18446744073709551615ULL +#endif // ULLONG_MAX + +namespace aria2 { + +namespace util { + +const std::string DEFAULT_TRIM_CHARSET("\r\n\t "); + +std::string trim(const std::string& src, const std::string& trimCharset) +{ + std::string temp(src); + trimSelf(temp, trimCharset); + return temp; +} + +void trimSelf(std::string& str, const std::string& trimCharset) +{ + std::string::size_type first = str.find_first_not_of(trimCharset); + if(first == std::string::npos) { + str.clear(); + } else { + std::string::size_type last = str.find_last_not_of(trimCharset)+1; + str.erase(last); + str.erase(0, first); + } +} + +void split(std::pair& hp, const std::string& src, char delim) +{ + hp.first = A2STR::NIL; + hp.second = A2STR::NIL; + std::string::size_type p = src.find(delim); + if(p == std::string::npos) { + hp.first = src; + hp.second = A2STR::NIL; + } else { + hp.first = trim(src.substr(0, p)); + hp.second = trim(src.substr(p+1)); + } +} + +std::pair split(const std::string& src, const std::string& delims) +{ + std::pair hp; + hp.first = A2STR::NIL; + hp.second = A2STR::NIL; + std::string::size_type p = src.find_first_of(delims); + if(p == std::string::npos) { + hp.first = src; + hp.second = A2STR::NIL; + } else { + hp.first = trim(src.substr(0, p)); + hp.second = trim(src.substr(p+1)); + } + return hp; +} + +int64_t difftv(struct timeval tv1, struct timeval tv2) { + if((tv1.tv_sec < tv2.tv_sec) || + ((tv1.tv_sec == tv2.tv_sec) && (tv1.tv_usec < tv2.tv_usec))) { + return 0; + } + return ((int64_t)(tv1.tv_sec-tv2.tv_sec)*1000000+ + tv1.tv_usec-tv2.tv_usec); +} + +int32_t difftvsec(struct timeval tv1, struct timeval tv2) { + if(tv1.tv_sec < tv2.tv_sec) { + return 0; + } + return tv1.tv_sec-tv2.tv_sec; +} + +bool startsWith(const std::string& target, const std::string& part) { + if(target.size() < part.size()) { + return false; + } + if(part.empty()) { + return true; + } + if(target.find(part) == 0) { + return true; + } else { + return false; + } +} + +bool endsWith(const std::string& target, const std::string& part) { + if(target.size() < part.size()) { + return false; + } + if(part.empty()) { + return true; + } + if(target.rfind(part) == target.size()-part.size()) { + return true; + } else { + return false; + } +} + +std::string replace(const std::string& target, const std::string& oldstr, const std::string& newstr) { + if(target.empty() || oldstr.empty()) { + return target; + } + std::string result; + std::string::size_type p = 0; + std::string::size_type np = target.find(oldstr); + while(np != std::string::npos) { + result += target.substr(p, np-p); + result += newstr; + p = np+oldstr.size(); + np = target.find(oldstr, p); + } + result += target.substr(p); + + return result; +} + +bool inRFC3986ReservedChars(const char c) +{ + static const char reserved[] = { + ':' , '/' , '?' , '#' , '[' , ']' , '@', + '!' , '$' , '&' , '\'' , '(' , ')', + '*' , '+' , ',' , ';' , '=' }; + return std::find(&reserved[0], &reserved[arrayLength(reserved)], c) != + &reserved[arrayLength(reserved)]; +} + +bool inRFC3986UnreservedChars(const char c) +{ + static const char unreserved[] = { '-', '.', '_', '~' }; + return + // ALPHA + ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || + // DIGIT + ('0' <= c && c <= '9') || + std::find(&unreserved[0], &unreserved[arrayLength(unreserved)], c) != + &unreserved[arrayLength(unreserved)]; +} + +std::string urlencode(const unsigned char* target, size_t len) { + std::string dest; + for(size_t i = 0; i < len; ++i) { + if(!inRFC3986UnreservedChars(target[i])) { + dest.append(StringFormat("%%%02X", target[i]).str()); + } else { + dest += target[i]; + } + } + return dest; +} + +std::string urlencode(const std::string& target) +{ + return urlencode((const unsigned char*)target.c_str(), target.size()); +} + +std::string torrentUrlencode(const unsigned char* target, size_t len) { + std::string dest; + for(size_t i = 0; i < len; ++i) { + if(('0' <= target[i] && target[i] <= '9') || + ('A' <= target[i] && target[i] <= 'Z') || + ('a' <= target[i] && target[i] <= 'z')) { + dest += target[i]; + } else { + dest.append(StringFormat("%%%02X", target[i]).str()); + } + } + return dest; +} + +std::string torrentUrlencode(const std::string& target) +{ + return torrentUrlencode + (reinterpret_cast(target.c_str()), target.size()); +} + +std::string urldecode(const std::string& target) { + std::string result; + for(std::string::const_iterator itr = target.begin(); + itr != target.end(); ++itr) { + if(*itr == '%') { + if(itr+1 != target.end() && itr+2 != target.end() && + isxdigit(*(itr+1)) && isxdigit(*(itr+2))) { + result += parseInt(std::string(itr+1, itr+3), 16); + itr += 2; + } else { + result += *itr; + } + } else { + result += *itr; + } + } + return result; +} + +std::string toHex(const unsigned char* src, size_t len) { + char* temp = new char[len*2+1]; + for(size_t i = 0; i < len; ++i) { + sprintf(temp+i*2, "%02x", src[i]); + } + temp[len*2] = '\0'; + std::string hex = temp; + delete [] temp; + return hex; +} + +std::string toHex(const char* src, size_t len) +{ + return toHex(reinterpret_cast(src), len); +} + +std::string toHex(const std::string& src) +{ + return toHex(reinterpret_cast(src.c_str()), src.size()); +} + +FILE* openFile(const std::string& filename, const std::string& mode) { + FILE* file = fopen(filename.c_str(), mode.c_str()); + return file; +} + +bool isPowerOf(int num, int base) { + if(base <= 0) { return false; } + if(base == 1) { return true; } + + while(num%base == 0) { + num /= base; + if(num == 1) { + return true; + } + } + return false; +} + +std::string secfmt(time_t sec) { + std::string str; + if(sec >= 3600) { + str = itos(sec/3600); + str += "h"; + sec %= 3600; + } + if(sec >= 60) { + int min = sec/60; + if(min < 10) { + str += "0"; + } + str += itos(min); + str += "m"; + sec %= 60; + } + if(sec < 10) { + str += "0"; + } + str += itos(sec); + str += "s"; + return str; +} + +int getNum(const char* buf, int offset, size_t length) { + char* temp = new char[length+1]; + memcpy(temp, buf+offset, length); + temp[length] = '\0'; + int x = strtol(temp, 0, 10); + delete [] temp; + return x; +} + +int32_t parseInt(const std::string& s, int32_t base) +{ + std::string trimed = trim(s); + if(trimed.empty()) { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + "empty string").str()); + } + char* stop; + errno = 0; + long int v = strtol(trimed.c_str(), &stop, base); + if(*stop != '\0') { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + trimed.c_str()).str()); + } else if((((v == LONG_MIN) || (v == LONG_MAX)) && (errno == ERANGE)) || + (v > INT32_MAX) || + (v < INT32_MIN)) { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + trimed.c_str()).str()); + } + return v; +} + +uint32_t parseUInt(const std::string& s, int base) +{ + std::string trimed = trim(s); + if(trimed.empty()) { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + "empty string").str()); + } + // We don't allow negative number. + if(trimed[0] == '-') { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + trimed.c_str()).str()); + } + char* stop; + errno = 0; + unsigned long int v = strtoul(trimed.c_str(), &stop, base); + if(*stop != '\0') { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + trimed.c_str()).str()); + } else if(((v == ULONG_MAX) && (errno == ERANGE)) || (v > UINT32_MAX)) { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + trimed.c_str()).str()); + } + return v; +} + +int64_t parseLLInt(const std::string& s, int32_t base) +{ + std::string trimed = trim(s); + if(trimed.empty()) { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + "empty string").str()); + } + char* stop; + errno = 0; + int64_t v = strtoll(trimed.c_str(), &stop, base); + if(*stop != '\0') { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + trimed.c_str()).str()); + } else if(((v == INT64_MIN) || (v == INT64_MAX)) && (errno == ERANGE)) { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + trimed.c_str()).str()); + } + return v; +} + +uint64_t parseULLInt(const std::string& s, int base) +{ + std::string trimed = trim(s); + if(trimed.empty()) { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + "empty string").str()); + } + // We don't allow negative number. + if(trimed[0] == '-') { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + trimed.c_str()).str()); + } + char* stop; + errno = 0; + uint64_t v = strtoull(trimed.c_str(), &stop, base); + if(*stop != '\0') { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + trimed.c_str()).str()); + } else if((v == ULLONG_MAX) && (errno == ERANGE)) { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + trimed.c_str()).str()); + } + return v; +} + +IntSequence parseIntRange(const std::string& src) +{ + IntSequence::Values values; + std::string temp = src; + while(temp.size()) { + std::pair p = split(temp, ","); + temp = p.second; + if(p.first.empty()) { + continue; + } + if(p.first.find("-") == std::string::npos) { + int32_t v = parseInt(p.first.c_str()); + values.push_back(IntSequence::Value(v, v+1)); + } else { + std::pair vp = split(p.first.c_str(), "-"); + if(vp.first.empty() || vp.second.empty()) { + throw DL_ABORT_EX + (StringFormat(MSG_INCOMPLETE_RANGE, p.first.c_str()).str()); + } + int32_t v1 = parseInt(vp.first.c_str()); + int32_t v2 = parseInt(vp.second.c_str()); + values.push_back(IntSequence::Value(v1, v2+1)); + } + } + return values; +} + +std::string getContentDispositionFilename(const std::string& header) { + static const std::string keyName = "filename="; + std::string::size_type attributesp = header.find(keyName); + if(attributesp == std::string::npos) { + return A2STR::NIL; + } + std::string::size_type filenamesp = attributesp+keyName.size(); + std::string::size_type filenameep; + if(filenamesp == header.size()) { + return A2STR::NIL; + } + + if(header[filenamesp] == '\'' || header[filenamesp] == '"') { + char quoteChar = header[filenamesp]; + filenameep = header.find(quoteChar, filenamesp+1); + } else { + filenameep = header.find(';', filenamesp); + } + if(filenameep == std::string::npos) { + filenameep = header.size(); + } + static const std::string TRIMMED("\r\n '\""); + std::string fn = + File(trim(header.substr + (filenamesp, filenameep-filenamesp), TRIMMED)).getBasename(); + if(fn == ".." || fn == ".") { + return A2STR::NIL; + } else { + return fn; + } +} + +std::string randomAlpha(size_t length, const RandomizerHandle& randomizer) { + static const char *random_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + std::string str; + for(size_t i = 0; i < length; ++i) { + size_t index = randomizer->getRandomNumber(strlen(random_chars)); + str += random_chars[index]; + } + return str; +} + +std::string toUpper(const std::string& src) { + std::string temp = src; + std::transform(temp.begin(), temp.end(), temp.begin(), ::toupper); + return temp; +} + +std::string toLower(const std::string& src) { + std::string temp = src; + std::transform(temp.begin(), temp.end(), temp.begin(), ::tolower); + return temp; +} + +bool isNumbersAndDotsNotation(const std::string& name) { + struct sockaddr_in sockaddr; + if(inet_aton(name.c_str(), &sockaddr.sin_addr)) { + return true; + } else { + return false; + } +} + +void setGlobalSignalHandler(int sig, void (*handler)(int), int flags) { +#ifdef HAVE_SIGACTION + struct sigaction sigact; + sigact.sa_handler = handler; + sigact.sa_flags = flags; + sigemptyset(&sigact.sa_mask); + sigaction(sig, &sigact, NULL); +#else + signal(sig, handler); +#endif // HAVE_SIGACTION +} + +std::string getHomeDir() +{ + const char* p = getenv("HOME"); + if(p) { + return p; + } else { + return A2STR::NIL; + } +} + +int64_t getRealSize(const std::string& sizeWithUnit) +{ + std::string::size_type p = sizeWithUnit.find_first_of("KM"); + std::string size; + int32_t mult = 1; + if(p == std::string::npos) { + size = sizeWithUnit; + } else { + if(sizeWithUnit[p] == 'K') { + mult = 1024; + } else if(sizeWithUnit[p] == 'M') { + mult = 1024*1024; + } + size = sizeWithUnit.substr(0, p); + } + int64_t v = parseLLInt(size); + + if(v < 0) { + throw DL_ABORT_EX + (StringFormat("Negative value detected: %s", sizeWithUnit.c_str()).str()); + } else if(INT64_MAX/mult < v) { + throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, + "overflow/underflow").str()); + } + return v*mult; +} + +std::string abbrevSize(int64_t size) +{ + if(size < 1024) { + return itos(size, true); + } + char units[] = { 'K', 'M' }; + size_t numUnit = sizeof(units)/sizeof(char); + size_t i = 0; + int r = size&0x3ff; + size >>= 10; + for(; i < numUnit-1 && size >= 1024; ++i) { + r = size&0x3ff; + size >>= 10; + } + std::string result = itos(size, true); + result += "."; + result += itos(r*10/1024); + result += units[i]; + result += "i"; + return result; +} + +void sleep(long seconds) { +#ifdef HAVE_SLEEP + ::sleep(seconds); +#elif defined(HAVE_USLEEP) + ::usleep(seconds * 1000000); +#elif defined(HAVE_WINSOCK2_H) + ::Sleep(seconds * 1000); +#else +#error no sleep function is available (nanosleep?) +#endif +} + +void usleep(long microseconds) { +#ifdef HAVE_USLEEP + ::usleep(microseconds); +#elif defined(HAVE_WINSOCK2_H) + + LARGE_INTEGER current, freq, end; + + static enum {GET_FREQUENCY, GET_MICROSECONDS, SKIP_MICROSECONDS} state = GET_FREQUENCY; + + if (state == GET_FREQUENCY) { + if (QueryPerformanceFrequency(&freq)) + state = GET_MICROSECONDS; + else + state = SKIP_MICROSECONDS; + } + + long msec = microseconds / 1000; + microseconds %= 1000; + + if (state == GET_MICROSECONDS && microseconds) { + QueryPerformanceCounter(&end); + + end.QuadPart += (freq.QuadPart * microseconds) / 1000000; + + while (QueryPerformanceCounter(¤t) && (current.QuadPart <= end.QuadPart)) + /* noop */ ; + } + + if (msec) + Sleep(msec); +#else + #error no usleep function is available (nanosleep?) +#endif +} + +bool isNumber(const std::string& what) +{ + if(what.empty()) { + return false; + } + for(uint32_t i = 0; i < what.size(); ++i) { + if(!isdigit(what[i])) { + return false; + } + } + return true; +} + +bool isLowercase(const std::string& what) +{ + if(what.empty()) { + return false; + } + for(uint32_t i = 0; i < what.size(); ++i) { + if(!('a' <= what[i] && what[i] <= 'z')) { + return false; + } + } + return true; +} + +bool isUppercase(const std::string& what) +{ + if(what.empty()) { + return false; + } + for(uint32_t i = 0; i < what.size(); ++i) { + if(!('A' <= what[i] && what[i] <= 'Z')) { + return false; + } + } + return true; +} + +unsigned int alphaToNum(const std::string& alphabets) +{ + if(alphabets.empty()) { + return 0; + } + char base; + if(islower(alphabets[0])) { + base = 'a'; + } else { + base = 'A'; + } + uint64_t num = 0; + for(size_t i = 0; i < alphabets.size(); ++i) { + unsigned int v = alphabets[i]-base; + num = num*26+v; + if(num > UINT32_MAX) { + return 0; + } + } + return num; +} + +void mkdirs(const std::string& dirpath) +{ + File dir(dirpath); + if(dir.isDir()) { + // do nothing + } else if(dir.exists()) { + throw DL_ABORT_EX + (StringFormat(EX_MAKE_DIR, dir.getPath().c_str(), + "File already exists.").str()); + } else if(!dir.mkdirs()) { + throw DL_ABORT_EX + (StringFormat(EX_MAKE_DIR, dir.getPath().c_str(), + strerror(errno)).str()); + } +} + +void convertBitfield(BitfieldMan* dest, const BitfieldMan* src) +{ + size_t numBlock = dest->countBlock(); + for(size_t index = 0; index < numBlock; ++index) { + if(src->isBitSetOffsetRange((uint64_t)index*dest->getBlockLength(), + dest->getBlockLength())) { + dest->setBit(index); + } + } +} + +std::string toString(const BinaryStreamHandle& binaryStream) +{ + std::stringstream strm; + char data[2048]; + while(1) { + int32_t dataLength = binaryStream->readData((unsigned char*)data, sizeof(data), strm.tellp()); + strm.write(data, dataLength); + if(dataLength == 0) { + break; + } + } + return strm.str(); +} + +#ifdef HAVE_POSIX_MEMALIGN +/** + * In linux 2.6, alignment and size should be a multiple of 512. + */ +void* allocateAlignedMemory(size_t alignment, size_t size) +{ + void* buffer; + int res; + if((res = posix_memalign(&buffer, alignment, size)) != 0) { + throw FATAL_EXCEPTION + (StringFormat("Error in posix_memalign: %s", strerror(res)).str()); + } + return buffer; +} +#endif // HAVE_POSIX_MEMALIGN + +std::pair +getNumericNameInfo(const struct sockaddr* sockaddr, socklen_t len) +{ + char host[NI_MAXHOST]; + char service[NI_MAXSERV]; + int s = getnameinfo(sockaddr, len, host, NI_MAXHOST, service, NI_MAXSERV, + NI_NUMERICHOST|NI_NUMERICSERV); + if(s != 0) { + throw DL_ABORT_EX(StringFormat("Failed to get hostname and port. cause: %s", + gai_strerror(s)).str()); + } + return std::pair(host, atoi(service)); // TODO +} + +std::string htmlEscape(const std::string& src) +{ + std::string dest; + for(std::string::const_iterator i = src.begin(); i != src.end(); ++i) { + char ch = *i; + if(ch == '<') { + dest += "<"; + } else if(ch == '>') { + dest += ">"; + } else if(ch == '&') { + dest += "&"; + } else if(ch == '\'') { + dest += "'"; + } else if(ch == '"') { + dest += """; + } else { + dest += ch; + } + } + return dest; +} + +std::map::value_type +parseIndexPath(const std::string& line) +{ + std::pair p = split(line, "="); + size_t index = parseUInt(p.first); + if(p.second.empty()) { + throw DL_ABORT_EX(StringFormat("Path with index=%u is empty.", + static_cast(index)).str()); + } + return std::map::value_type(index, p.second); +} + +std::map createIndexPathMap(std::istream& i) +{ + std::map indexPathMap; + std::string line; + while(getline(i, line)) { + indexPathMap.insert(indexPathMap.begin(), parseIndexPath(line)); + } + return indexPathMap; +} + +void generateRandomData(unsigned char* data, size_t length) +{ +#ifdef HAVE_LIBGCRYPT + gcry_randomize(data, length, GCRY_STRONG_RANDOM); +#elif HAVE_LIBSSL + if(RAND_bytes(data, length) != 1) { + for(size_t i = 0; i < length; ++i) { + data[i] = SimpleRandomizer::getInstance()->getRandomNumber(UINT8_MAX+1); + } + } +#else + std::ifstream i("/dev/urandom", std::ios::binary); + i.read(data, length); +#endif // HAVE_LIBSSL +} + +} // namespace util + +} // namespace aria2 diff --git a/src/util.h b/src/util.h new file mode 100644 index 00000000..eceb38cb --- /dev/null +++ b/src/util.h @@ -0,0 +1,327 @@ +/* */ +#ifndef _D_UTIL_H_ +#define _D_UTIL_H_ + +#include "common.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SharedHandle.h" +#include "IntSequence.h" +#include "a2time.h" +#include "a2netcompat.h" +#include "a2functional.h" + +namespace aria2 { + +class Randomizer; +class BitfieldMan; +class BinaryStream; +class FileEntry; + +#define STRTOLL(X) strtoll(X, (char**)0, 10) +#define STRTOULL(X) strtoull(X, (char**)0, 10) + +#define START_INDEX(OFFSET, PIECE_LENGTH) ((OFFSET)/(PIECE_LENGTH)) +#define END_INDEX(OFFSET, LENGTH, PIECE_LENGTH) (((OFFSET)+(LENGTH)-1)/(PIECE_LENGTH)) + +#define DIV_FLOOR(X,Y) ((X)/(Y)+((X)%(Y)? 1:0)) + +#ifdef WORDS_BIGENDIAN +inline uint64_t ntoh64(uint64_t x) { return x; } +inline uint64_t hton64(uint64_t x) { return x; } +#else // !WORDS_BIGENDIAN +inline uint64_t byteswap64(uint64_t x) { + uint64_t v1 = ntohl(x & 0x00000000ffffffff); + uint64_t v2 = ntohl(x >> 32); + return (v1 << 32)|v2; +} +inline uint64_t ntoh64(uint64_t x) { return byteswap64(x); } +inline uint64_t hton64(uint64_t x) { return byteswap64(x); } +#endif // !WORDS_BIGENDIAN + +namespace util { + +void split(std::pair& hp, + const std::string& src, char delim); + +std::pair +split(const std::string& src, const std::string& delims); + +template +std::string uitos(T value, bool comma = false) +{ + std::string str; + if(value == 0) { + str = "0"; + return str; + } + unsigned int count = 0; + while(value) { + ++count; + char digit = value%10+'0'; + str.insert(str.begin(), digit); + value /= 10; + if(comma && count > 3 && count%3 == 1) { + str.insert(str.begin()+1, ','); + } + } + return str; +} + +template +std::string itos(T value, bool comma = false) +{ + bool flag = false; + if(value < 0) { + flag = true; + value = -value; + } + std::string str = uitos(value, comma); + if(flag) { + str.insert(str.begin(), '-'); + } + return str; +} + +/** + * Computes difference in micro-seconds between tv1 and tv2, + * assuming tv1 is newer than tv2. + * If tv1 is older than tv2, then this method returns 0. + */ +int64_t difftv(struct timeval tv1, struct timeval tv2); +int32_t difftvsec(struct timeval tv1, struct timeval tv2); + +extern const std::string DEFAULT_TRIM_CHARSET; + +std::string trim(const std::string& src, + const std::string& trimCharset = DEFAULT_TRIM_CHARSET); + +void trimSelf(std::string& str, + const std::string& trimCharset = DEFAULT_TRIM_CHARSET); + +bool startsWith(const std::string& target, const std::string& part); + +bool endsWith(const std::string& target, const std::string& part); + +std::string replace(const std::string& target, const std::string& oldstr, const std::string& newstr); + +std::string urlencode(const unsigned char* target, size_t len); + +std::string urlencode(const std::string& target); + +bool inRFC3986ReservedChars(const char c); + +bool inRFC3986UnreservedChars(const char c); + +std::string urldecode(const std::string& target); + +std::string torrentUrlencode(const unsigned char* target, size_t len); + +std::string torrentUrlencode(const std::string& target); + +std::string toHex(const unsigned char* src, size_t len); + +std::string toHex(const char* src, size_t len); + +std::string toHex(const std::string& src); + +FILE* openFile(const std::string& filename, const std::string& mode); + +bool isPowerOf(int num, int base); + +std::string secfmt(time_t sec); + +int32_t parseInt(const std::string& s, int32_t base = 10); + +uint32_t parseUInt(const std::string& s, int base = 10); + +int64_t parseLLInt(const std::string& s, int32_t base = 10); + +uint64_t parseULLInt(const std::string& s, int base = 10); + +IntSequence parseIntRange(const std::string& src); + +// this function temporarily put here +std::string getContentDispositionFilename(const std::string& header); + +std::string randomAlpha(size_t length, + const SharedHandle& randomizer); + +std::string toUpper(const std::string& src); + +std::string toLower(const std::string& src); + +bool isNumbersAndDotsNotation(const std::string& name); + +void setGlobalSignalHandler(int signal, void (*handler)(int), int flags); + +std::string getHomeDir(); + +int64_t getRealSize(const std::string& sizeWithUnit); + +std::string abbrevSize(int64_t size); + +template +void toStream +(InputIterator first, InputIterator last, std::ostream& os) +{ + os << _("Files:") << "\n"; + os << "idx|path/length" << "\n"; + os << "===+===========================================================================" << "\n"; + int32_t count = 1; + for(; first != last; ++first, ++count) { + os << std::setw(3) << count << "|" << (*first)->getPath() << "\n"; + os << " |" << util::abbrevSize((*first)->getLength()) << "B (" + << util::uitos((*first)->getLength(), true) << ")\n"; + os << "---+---------------------------------------------------------------------------" << "\n"; + } +} + +void sleep(long seconds); + +void usleep(long microseconds); + +bool isNumber(const std::string& what); + +bool isLowercase(const std::string& what); + +bool isUppercase(const std::string& what); + +/** + * Converts alphabets to unsigned int, assuming alphabets as a base 26 + * integer and 'a' or 'A' is 0. + * This function assumes alphabets includes only a-z. + * Upper case are allowed but all letters must be upper case. + * If overflow occurs, returns 0. + */ +unsigned int alphaToNum(const std::string& alphabets); + +void mkdirs(const std::string& dirpath); + +void convertBitfield(BitfieldMan* dest, const BitfieldMan* src); + +// binaryStream has to be opened before calling this function. +std::string toString(const SharedHandle& binaryStream); + +#ifdef HAVE_POSIX_MEMALIGN +void* allocateAlignedMemory(size_t alignment, size_t size); +#endif // HAVE_POSIX_MEMALIGN + +std::pair +getNumericNameInfo(const struct sockaddr* sockaddr, socklen_t len); + +std::string htmlEscape(const std::string& src); + +// Joins path element specified in [first, last). If ".." is found, +// it eats the previous element if it exists. If "." is found, it +// is just ignored and it is not appeared in the result. +template +std::string joinPath(InputIterator first, InputIterator last) +{ + std::deque elements; + for(;first != last; ++first) { + if(*first == "..") { + if(!elements.empty()) { + elements.pop_back(); + } + } else if(*first == ".") { + // do nothing + } else { + elements.push_back(*first); + } + } + return strjoin(elements.begin(), elements.end(), "/"); +} + +// Parses INDEX=PATH format string. INDEX must be an unsigned +// integer. +std::map::value_type +parseIndexPath(const std::string& line); + +std::map createIndexPathMap(std::istream& i); + +/** + * Take a string src which is a deliminated list and add its elements + * into result. result is stored in out. + */ +template +OutputIterator split(const std::string& src, OutputIterator out, + const std::string& delims, bool doTrim = false) +{ + std::string::size_type p = 0; + while(1) { + std::string::size_type np = src.find_first_of(delims, p); + if(np == std::string::npos) { + std::string term = src.substr(p); + if(doTrim) { + term = util::trim(term); + } + if(!term.empty()) { + *out = term; + ++out; + } + break; + } + std::string term = src.substr(p, np-p); + if(doTrim) { + term = util::trim(term); + } + p = np+1; + if(!term.empty()) { + *out = term; + ++out; + } + } + return out; +} + +void generateRandomData(unsigned char* data, size_t length); + +} // namespace util + +} // namespace aria2 + +#endif // _D_UTIL_H_ diff --git a/src/version_usage.cc b/src/version_usage.cc index 8658faf6..746cca59 100644 --- a/src/version_usage.cc +++ b/src/version_usage.cc @@ -49,7 +49,7 @@ #include "StringFormat.h" #include "OptionParser.h" #include "OptionHandler.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/ARC4Test.cc b/test/ARC4Test.cc index 804d749b..0f6b672b 100644 --- a/test/ARC4Test.cc +++ b/test/ARC4Test.cc @@ -5,7 +5,7 @@ #include "ARC4Decryptor.h" #include "Exception.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/BDETest.cc b/test/BDETest.cc index e311cf86..b70da967 100644 --- a/test/BDETest.cc +++ b/test/BDETest.cc @@ -4,7 +4,7 @@ #include -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/BNodeTest.cc b/test/BNodeTest.cc index a01329d2..0cf1d8a2 100644 --- a/test/BNodeTest.cc +++ b/test/BNodeTest.cc @@ -6,7 +6,7 @@ #include "DHTNode.h" #include "DHTBucket.h" #include "Exception.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/BittorrentHelperTest.cc b/test/BittorrentHelperTest.cc index 0d498c61..246a98d0 100644 --- a/test/BittorrentHelperTest.cc +++ b/test/BittorrentHelperTest.cc @@ -6,7 +6,7 @@ #include #include "DownloadContext.h" -#include "Util.h" +#include "util.h" #include "RecoverableException.h" #include "AnnounceTier.h" #include "FixedNumberRandomizer.h" diff --git a/test/BtAllowedFastMessageTest.cc b/test/BtAllowedFastMessageTest.cc index 8bd7b162..0a180d84 100644 --- a/test/BtAllowedFastMessageTest.cc +++ b/test/BtAllowedFastMessageTest.cc @@ -4,7 +4,7 @@ #include #include "bittorrent_helper.h" -#include "Util.h" +#include "util.h" #include "Peer.h" namespace aria2 { diff --git a/test/BtBitfieldMessageTest.cc b/test/BtBitfieldMessageTest.cc index 68fbd042..5f51c6c9 100644 --- a/test/BtBitfieldMessageTest.cc +++ b/test/BtBitfieldMessageTest.cc @@ -5,7 +5,7 @@ #include #include "bittorrent_helper.h" -#include "Util.h" +#include "util.h" #include "Peer.h" #include "MockPieceStorage.h" #include "DlAbortEx.h" diff --git a/test/BtHandshakeMessageTest.cc b/test/BtHandshakeMessageTest.cc index c70ed360..b49f2227 100644 --- a/test/BtHandshakeMessageTest.cc +++ b/test/BtHandshakeMessageTest.cc @@ -4,7 +4,7 @@ #include -#include "Util.h" +#include "util.h" #include "BtConstants.h" namespace aria2 { diff --git a/test/BtPortMessageTest.cc b/test/BtPortMessageTest.cc index b2ebe841..8f212d70 100644 --- a/test/BtPortMessageTest.cc +++ b/test/BtPortMessageTest.cc @@ -5,7 +5,7 @@ #include #include "bittorrent_helper.h" -#include "Util.h" +#include "util.h" #include "array_fun.h" #include "Peer.h" #include "DHTNode.h" diff --git a/test/CookieStorageTest.cc b/test/CookieStorageTest.cc index 7c6957f4..29044a6b 100644 --- a/test/CookieStorageTest.cc +++ b/test/CookieStorageTest.cc @@ -6,7 +6,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "TimeA2.h" #include "CookieParser.h" #include "RecoverableException.h" diff --git a/test/CookieTest.cc b/test/CookieTest.cc index 0ec0727e..e18bf96d 100644 --- a/test/CookieTest.cc +++ b/test/CookieTest.cc @@ -5,7 +5,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "TimeA2.h" namespace aria2 { diff --git a/test/DHKeyExchangeTest.cc b/test/DHKeyExchangeTest.cc index 8c31d6eb..4ec10ecf 100644 --- a/test/DHKeyExchangeTest.cc +++ b/test/DHKeyExchangeTest.cc @@ -1,6 +1,6 @@ #include "DHKeyExchange.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include namespace aria2 { diff --git a/test/DHTAnnouncePeerMessageTest.cc b/test/DHTAnnouncePeerMessageTest.cc index 698d0201..e1908154 100644 --- a/test/DHTAnnouncePeerMessageTest.cc +++ b/test/DHTAnnouncePeerMessageTest.cc @@ -4,7 +4,7 @@ #include "DHTNode.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "MockDHTMessageFactory.h" #include "MockDHTMessageDispatcher.h" #include "MockDHTMessage.h" diff --git a/test/DHTAnnouncePeerReplyMessageTest.cc b/test/DHTAnnouncePeerReplyMessageTest.cc index af3ab22e..de7e0f92 100644 --- a/test/DHTAnnouncePeerReplyMessageTest.cc +++ b/test/DHTAnnouncePeerReplyMessageTest.cc @@ -4,7 +4,7 @@ #include "DHTNode.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "bencode.h" namespace aria2 { diff --git a/test/DHTBucketTest.cc b/test/DHTBucketTest.cc index 28ce240b..3ee56497 100644 --- a/test/DHTBucketTest.cc +++ b/test/DHTBucketTest.cc @@ -7,7 +7,7 @@ #include "DHTNode.h" #include "Exception.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/DHTFindNodeMessageTest.cc b/test/DHTFindNodeMessageTest.cc index 93354586..8e01b2b3 100644 --- a/test/DHTFindNodeMessageTest.cc +++ b/test/DHTFindNodeMessageTest.cc @@ -4,7 +4,7 @@ #include "DHTNode.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "MockDHTMessageFactory.h" #include "MockDHTMessage.h" #include "MockDHTMessageDispatcher.h" diff --git a/test/DHTFindNodeReplyMessageTest.cc b/test/DHTFindNodeReplyMessageTest.cc index 0e58e60d..e5bba6b1 100644 --- a/test/DHTFindNodeReplyMessageTest.cc +++ b/test/DHTFindNodeReplyMessageTest.cc @@ -4,7 +4,7 @@ #include "DHTNode.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "DHTBucket.h" #include "bittorrent_helper.h" #include "bencode.h" diff --git a/test/DHTGetPeersMessageTest.cc b/test/DHTGetPeersMessageTest.cc index bbe96ccb..28c5d229 100644 --- a/test/DHTGetPeersMessageTest.cc +++ b/test/DHTGetPeersMessageTest.cc @@ -4,7 +4,7 @@ #include "DHTNode.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "MockDHTMessageFactory.h" #include "MockDHTMessage.h" #include "MockDHTMessageDispatcher.h" diff --git a/test/DHTGetPeersReplyMessageTest.cc b/test/DHTGetPeersReplyMessageTest.cc index b509b8a3..b3176365 100644 --- a/test/DHTGetPeersReplyMessageTest.cc +++ b/test/DHTGetPeersReplyMessageTest.cc @@ -4,7 +4,7 @@ #include "DHTNode.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "DHTBucket.h" #include "bittorrent_helper.h" #include "Peer.h" diff --git a/test/DHTIDCloserTest.cc b/test/DHTIDCloserTest.cc index e5d3cdf5..09a0e519 100644 --- a/test/DHTIDCloserTest.cc +++ b/test/DHTIDCloserTest.cc @@ -2,7 +2,7 @@ #include "DHTNodeLookupEntry.h" #include "DHTIDCloser.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include #include #include diff --git a/test/DHTMessageFactoryImplTest.cc b/test/DHTMessageFactoryImplTest.cc index c312bd6f..de0af760 100644 --- a/test/DHTMessageFactoryImplTest.cc +++ b/test/DHTMessageFactoryImplTest.cc @@ -6,7 +6,7 @@ #include #include "RecoverableException.h" -#include "Util.h" +#include "util.h" #include "DHTNode.h" #include "DHTRoutingTable.h" #include "Peer.h" diff --git a/test/DHTMessageTrackerEntryTest.cc b/test/DHTMessageTrackerEntryTest.cc index 9dea3874..891fd4b9 100644 --- a/test/DHTMessageTrackerEntryTest.cc +++ b/test/DHTMessageTrackerEntryTest.cc @@ -5,7 +5,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "MockDHTMessage.h" #include "DHTNode.h" #include "DHTMessageCallback.h" diff --git a/test/DHTMessageTrackerTest.cc b/test/DHTMessageTrackerTest.cc index cd4d5d2e..0b8e49a4 100644 --- a/test/DHTMessageTrackerTest.cc +++ b/test/DHTMessageTrackerTest.cc @@ -3,7 +3,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "MockDHTMessage.h" #include "MockDHTMessageCallback.h" #include "DHTNode.h" diff --git a/test/DHTNodeTest.cc b/test/DHTNodeTest.cc index 179ead55..3ec16ab4 100644 --- a/test/DHTNodeTest.cc +++ b/test/DHTNodeTest.cc @@ -1,6 +1,6 @@ #include "DHTNode.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include #include diff --git a/test/DHTPeerAnnounceEntryTest.cc b/test/DHTPeerAnnounceEntryTest.cc index b679d783..cc79afce 100644 --- a/test/DHTPeerAnnounceEntryTest.cc +++ b/test/DHTPeerAnnounceEntryTest.cc @@ -5,7 +5,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "MockPeerStorage.h" #include "FileEntry.h" diff --git a/test/DHTPeerAnnounceStorageTest.cc b/test/DHTPeerAnnounceStorageTest.cc index 698fc72a..48a3d71a 100644 --- a/test/DHTPeerAnnounceStorageTest.cc +++ b/test/DHTPeerAnnounceStorageTest.cc @@ -5,7 +5,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "DownloadContext.h" #include "MockPeerStorage.h" #include "DHTConstants.h" diff --git a/test/DHTPingMessageTest.cc b/test/DHTPingMessageTest.cc index af93b854..e81983e6 100644 --- a/test/DHTPingMessageTest.cc +++ b/test/DHTPingMessageTest.cc @@ -4,7 +4,7 @@ #include "DHTNode.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "MockDHTMessageFactory.h" #include "MockDHTMessageDispatcher.h" #include "MockDHTMessage.h" diff --git a/test/DHTPingReplyMessageTest.cc b/test/DHTPingReplyMessageTest.cc index d8fdb5b8..38a4dbde 100644 --- a/test/DHTPingReplyMessageTest.cc +++ b/test/DHTPingReplyMessageTest.cc @@ -4,7 +4,7 @@ #include "DHTNode.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "bencode.h" namespace aria2 { diff --git a/test/DHTRoutingTableDeserializerTest.cc b/test/DHTRoutingTableDeserializerTest.cc index ee4ab142..f5026b8e 100644 --- a/test/DHTRoutingTableDeserializerTest.cc +++ b/test/DHTRoutingTableDeserializerTest.cc @@ -8,7 +8,7 @@ #include "DHTRoutingTableSerializer.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "DHTNode.h" #include "array_fun.h" #include "DHTConstants.h" diff --git a/test/DHTRoutingTableSerializerTest.cc b/test/DHTRoutingTableSerializerTest.cc index 428b2e34..09409c76 100644 --- a/test/DHTRoutingTableSerializerTest.cc +++ b/test/DHTRoutingTableSerializerTest.cc @@ -1,6 +1,6 @@ #include "DHTRoutingTableSerializer.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "DHTNode.h" #include "array_fun.h" #include "DHTConstants.h" diff --git a/test/DHTRoutingTableTest.cc b/test/DHTRoutingTableTest.cc index 486da953..67a3bb9f 100644 --- a/test/DHTRoutingTableTest.cc +++ b/test/DHTRoutingTableTest.cc @@ -4,7 +4,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "DHTNode.h" #include "DHTBucket.h" #include "MockDHTTaskQueue.h" diff --git a/test/DHTTokenTrackerTest.cc b/test/DHTTokenTrackerTest.cc index 990e4e09..da779ac5 100644 --- a/test/DHTTokenTrackerTest.cc +++ b/test/DHTTokenTrackerTest.cc @@ -3,7 +3,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "DHTConstants.h" namespace aria2 { diff --git a/test/DefaultBtAnnounceTest.cc b/test/DefaultBtAnnounceTest.cc index 8205c3f9..78d8d9ce 100644 --- a/test/DefaultBtAnnounceTest.cc +++ b/test/DefaultBtAnnounceTest.cc @@ -5,7 +5,7 @@ #include #include "Option.h" -#include "Util.h" +#include "util.h" #include "Exception.h" #include "MockPieceStorage.h" #include "MockPeerStorage.h" diff --git a/test/DefaultBtMessageDispatcherTest.cc b/test/DefaultBtMessageDispatcherTest.cc index 4c620406..6e37e531 100644 --- a/test/DefaultBtMessageDispatcherTest.cc +++ b/test/DefaultBtMessageDispatcherTest.cc @@ -4,7 +4,7 @@ #include -#include "Util.h" +#include "util.h" #include "Exception.h" #include "MockPieceStorage.h" #include "MockPeerStorage.h" diff --git a/test/DefaultBtProgressInfoFileTest.cc b/test/DefaultBtProgressInfoFileTest.cc index 0e077e1a..cbdbb15b 100644 --- a/test/DefaultBtProgressInfoFileTest.cc +++ b/test/DefaultBtProgressInfoFileTest.cc @@ -5,7 +5,7 @@ #include #include "Option.h" -#include "Util.h" +#include "util.h" #include "Exception.h" #include "MockPieceStorage.h" #include "prefs.h" diff --git a/test/DefaultPeerStorageTest.cc b/test/DefaultPeerStorageTest.cc index 6779cacd..8f910c9c 100644 --- a/test/DefaultPeerStorageTest.cc +++ b/test/DefaultPeerStorageTest.cc @@ -4,7 +4,7 @@ #include -#include "Util.h" +#include "util.h" #include "Exception.h" #include "Peer.h" #include "Option.h" diff --git a/test/DefaultPieceStorageTest.cc b/test/DefaultPieceStorageTest.cc index ef787c19..9693ca27 100644 --- a/test/DefaultPieceStorageTest.cc +++ b/test/DefaultPieceStorageTest.cc @@ -2,7 +2,7 @@ #include -#include "Util.h" +#include "util.h" #include "Exception.h" #include "FixedNumberRandomizer.h" #include "BitfieldManFactory.h" diff --git a/test/DirectDiskAdaptorTest.cc b/test/DirectDiskAdaptorTest.cc index b393ffb2..d5c642a2 100644 --- a/test/DirectDiskAdaptorTest.cc +++ b/test/DirectDiskAdaptorTest.cc @@ -5,7 +5,7 @@ #include "FileEntry.h" #include "DefaultDiskWriter.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "TestUtil.h" namespace aria2 { diff --git a/test/DownloadHelperTest.cc b/test/DownloadHelperTest.cc index 7255d63b..f0b9d393 100644 --- a/test/DownloadHelperTest.cc +++ b/test/DownloadHelperTest.cc @@ -13,7 +13,7 @@ #include "array_fun.h" #include "prefs.h" #include "Exception.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/FeatureConfigTest.cc b/test/FeatureConfigTest.cc index c2feb3a8..f28260a4 100644 --- a/test/FeatureConfigTest.cc +++ b/test/FeatureConfigTest.cc @@ -6,7 +6,7 @@ #include "a2functional.h" #include "array_fun.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/FeedbackURISelectorTest.cc b/test/FeedbackURISelectorTest.cc index 783f5680..4e3c33eb 100644 --- a/test/FeedbackURISelectorTest.cc +++ b/test/FeedbackURISelectorTest.cc @@ -3,7 +3,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "array_fun.h" #include "ServerStatMan.h" #include "ServerStat.h" diff --git a/test/FtpConnectionTest.cc b/test/FtpConnectionTest.cc index 5d636a40..caad1965 100644 --- a/test/FtpConnectionTest.cc +++ b/test/FtpConnectionTest.cc @@ -6,7 +6,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "SocketCore.h" #include "Request.h" #include "Option.h" diff --git a/test/GZipDecoderTest.cc b/test/GZipDecoderTest.cc index c42019fc..31aa8f2f 100644 --- a/test/GZipDecoderTest.cc +++ b/test/GZipDecoderTest.cc @@ -1,6 +1,6 @@ #include "GZipDecoder.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #ifdef ENABLE_MESSAGE_DIGEST # include "MessageDigestHelper.h" #endif // ENABLE_MESSAGE_DIGEST diff --git a/test/HttpRequestTest.cc b/test/HttpRequestTest.cc index 99d3e6aa..9c1f9cc3 100644 --- a/test/HttpRequestTest.cc +++ b/test/HttpRequestTest.cc @@ -13,7 +13,7 @@ #include "Option.h" #include "array_fun.h" #include "CookieStorage.h" -#include "Util.h" +#include "util.h" #include "AuthConfig.h" namespace aria2 { diff --git a/test/InOrderURISelectorTest.cc b/test/InOrderURISelectorTest.cc index 3663a9f9..9efc2f3c 100644 --- a/test/InOrderURISelectorTest.cc +++ b/test/InOrderURISelectorTest.cc @@ -3,7 +3,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "array_fun.h" #include "FileEntry.h" diff --git a/test/MSEHandshakeTest.cc b/test/MSEHandshakeTest.cc index 3eb78b5c..9750304f 100644 --- a/test/MSEHandshakeTest.cc +++ b/test/MSEHandshakeTest.cc @@ -5,7 +5,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "prefs.h" #include "Socket.h" #include "Option.h" diff --git a/test/MessageDigestHelperTest.cc b/test/MessageDigestHelperTest.cc index 576d3c03..b07bd48a 100644 --- a/test/MessageDigestHelperTest.cc +++ b/test/MessageDigestHelperTest.cc @@ -2,7 +2,7 @@ #include -#include "Util.h" +#include "util.h" #include "DefaultDiskWriter.h" namespace aria2 { diff --git a/test/NsCookieParserTest.cc b/test/NsCookieParserTest.cc index 055e9c14..21ca56c6 100644 --- a/test/NsCookieParserTest.cc +++ b/test/NsCookieParserTest.cc @@ -5,7 +5,7 @@ #include #include "RecoverableException.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/OptionParserTest.cc b/test/OptionParserTest.cc index e4188123..f70b32ef 100644 --- a/test/OptionParserTest.cc +++ b/test/OptionParserTest.cc @@ -8,7 +8,7 @@ #include "OptionHandlerImpl.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "Option.h" #include "array_fun.h" diff --git a/test/PeerSessionResourceTest.cc b/test/PeerSessionResourceTest.cc index f7a8a767..fc1078f9 100644 --- a/test/PeerSessionResourceTest.cc +++ b/test/PeerSessionResourceTest.cc @@ -4,7 +4,7 @@ #include "MockBtMessageDispatcher.h" #include "Exception.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/ProtocolDetectorTest.cc b/test/ProtocolDetectorTest.cc index e785bf83..7b6ccd99 100644 --- a/test/ProtocolDetectorTest.cc +++ b/test/ProtocolDetectorTest.cc @@ -1,6 +1,6 @@ #include "ProtocolDetector.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include #include diff --git a/test/ServerStatManTest.cc b/test/ServerStatManTest.cc index 265c04e1..8aa9f627 100644 --- a/test/ServerStatManTest.cc +++ b/test/ServerStatManTest.cc @@ -7,7 +7,7 @@ #include "ServerStat.h" #include "Exception.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/ServerStatTest.cc b/test/ServerStatTest.cc index 92903c7b..af9cd0ab 100644 --- a/test/ServerStatTest.cc +++ b/test/ServerStatTest.cc @@ -6,7 +6,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/Sqlite3MozCookieParserTest.cc b/test/Sqlite3MozCookieParserTest.cc index b0d528c2..ff685c64 100644 --- a/test/Sqlite3MozCookieParserTest.cc +++ b/test/Sqlite3MozCookieParserTest.cc @@ -5,7 +5,7 @@ #include #include "RecoverableException.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/StringFormatTest.cc b/test/StringFormatTest.cc index 8e7e36be..528d00b2 100644 --- a/test/StringFormatTest.cc +++ b/test/StringFormatTest.cc @@ -1,6 +1,6 @@ #include "StringFormat.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include #include diff --git a/test/TimeSeedCriteriaTest.cc b/test/TimeSeedCriteriaTest.cc index 1653f6f6..216dce71 100644 --- a/test/TimeSeedCriteriaTest.cc +++ b/test/TimeSeedCriteriaTest.cc @@ -2,7 +2,7 @@ #include -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/TimeTest.cc b/test/TimeTest.cc index b51e7ce5..b6a0d5c4 100644 --- a/test/TimeTest.cc +++ b/test/TimeTest.cc @@ -5,7 +5,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" namespace aria2 { diff --git a/test/UTPexExtensionMessageTest.cc b/test/UTPexExtensionMessageTest.cc index e4085bd0..b6653035 100644 --- a/test/UTPexExtensionMessageTest.cc +++ b/test/UTPexExtensionMessageTest.cc @@ -6,7 +6,7 @@ #include "Peer.h" #include "a2netcompat.h" -#include "Util.h" +#include "util.h" #include "bittorrent_helper.h" #include "MockPeerStorage.h" #include "Exception.h" diff --git a/test/UriListParserTest.cc b/test/UriListParserTest.cc index 4ad0f16e..d996172b 100644 --- a/test/UriListParserTest.cc +++ b/test/UriListParserTest.cc @@ -9,7 +9,7 @@ #include #include "Exception.h" -#include "Util.h" +#include "util.h" #include "prefs.h" #include "OptionHandler.h" diff --git a/test/UtilTest.cc b/test/UtilTest.cc index d0e1eede..b27e6181 100644 --- a/test/UtilTest.cc +++ b/test/UtilTest.cc @@ -1,4 +1,4 @@ -#include "Util.h" +#include "util.h" #include #include diff --git a/test/XORCloserTest.cc b/test/XORCloserTest.cc index 6da4bccf..08e905e3 100644 --- a/test/XORCloserTest.cc +++ b/test/XORCloserTest.cc @@ -1,6 +1,6 @@ #include "XORCloser.h" #include "Exception.h" -#include "Util.h" +#include "util.h" #include "DHTNodeLookupEntry.h" #include "DHTNode.h" #include -- cgit