Jelajahi Sumber

To add some useful information to the exception message:

	* src/SocketCore.cc : Updated messages.
	* src/SegmentMan.cc : 
	* src/TorrentMan.cc : Updated messages.
	* src/MultiDiskWriter.cc : Updated messages.
	* src/Util.cc : Updated messages.
	* src/AbstractDiskWriter.cc : Updated messages.
	* src/PreAllocationDiskWriter.cc : Updated messages.
	* src/message.cc : Added new messages. Updated some messages.

	* src/TrackerWatcherCommand.h (MIN_PEERS): New definition.
	* src/TrackerWatcherCommand.cc (execute): Use MIN_PEERS.
	Updated threshold from 30 to 15.

	* src/AbstractDiskWriter.h (filename): New variable.
	* src/AbstractDiskWriter.cc (openExistingFile): Assigned 
filename.
	(createFile): Assigned filename.
	
	* src/main.cc: Updated the help message for http-auth-scheme.
Tatsuhiro Tsujikawa 19 tahun lalu
induk
melakukan
536c07488b

+ 23 - 0
ChangeLog

@@ -1,3 +1,26 @@
+2006-04-21  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	To add some useful information to the exception message:
+
+	* src/SocketCore.cc : Updated messages.
+	* src/SegmentMan.cc : 
+	* src/TorrentMan.cc : Updated messages.
+	* src/MultiDiskWriter.cc : Updated messages.
+	* src/Util.cc : Updated messages.
+	* src/AbstractDiskWriter.cc : Updated messages.
+	* src/PreAllocationDiskWriter.cc : Updated messages.
+	* src/message.cc : Added new messages. Updated some messages.
+
+	* src/TrackerWatcherCommand.h (MIN_PEERS): New definition.
+	* src/TrackerWatcherCommand.cc (execute): Use MIN_PEERS.
+	Updated threshold from 30 to 15.
+
+	* src/AbstractDiskWriter.h (filename): New variable.
+	* src/AbstractDiskWriter.cc (openExistingFile): Assigned filename.
+	(createFile): Assigned filename.
+	
+	* src/main.cc: Updated the help message for http-auth-scheme.
+
 2006-04-20  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	To add TrackerUpdateCommand with which replaces

+ 198 - 49
po/aria2c.pot

@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: http://aria2.sourceforge.net/\n"
-"POT-Creation-Date: 2006-04-20 02:49+0900\n"
+"POT-Creation-Date: 2006-04-21 00:25+0900\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -77,6 +77,21 @@ msgstr ""
 msgid "CUID#%d - Unregistering cuid from segmentManager."
 msgstr ""
 
+#: src/message.h:43
+#, c-format
+msgid "CUID#%d - we got new piece. index=%d"
+msgstr ""
+
+#: src/message.h:44
+#, c-format
+msgid "CUID#%d - we got wrong piece. index=%d"
+msgstr ""
+
+#: src/message.h:46
+#, c-format
+msgid "Tracker returned warning message: %s"
+msgstr ""
+
 #: src/message.h:48
 #, c-format
 msgid "The segment file %s exists."
@@ -115,7 +130,7 @@ msgstr ""
 
 #: src/message.h:57
 #, c-format
-msgid "Too large chunk. size = %d"
+msgid "Too large chunk. size=%d"
 msgstr ""
 
 #: src/message.h:58
@@ -151,12 +166,12 @@ msgstr ""
 
 #: src/message.h:65
 #, c-format
-msgid "The response status is not successful. status = %d"
+msgid "The response status is not successful. status=%d"
 msgstr ""
 
 #: src/message.h:66
 #, c-format
-msgid "Too large file size. size = %lld"
+msgid "Too large file size. size=%lld"
 msgstr ""
 
 #: src/message.h:67
@@ -173,10 +188,147 @@ msgstr ""
 msgid "Size mismatch %lld != %lld"
 msgstr ""
 
+#: src/message.h:70
+msgid "Authorization failed."
+msgstr ""
+
 #: src/message.h:71
 msgid "Got EOF from the server."
 msgstr ""
 
+#: src/message.h:72
+msgid "Got EOF from peer."
+msgstr ""
+
+#: src/message.h:73
+msgid "Mulformed meta info."
+msgstr ""
+
+#: src/message.h:75
+#, c-format
+msgid "Failed to open the file %s, cause: %s"
+msgstr ""
+
+#: src/message.h:76
+#, c-format
+msgid "Failed to write into the file %s, cause: %s"
+msgstr ""
+
+#: src/message.h:77
+#, c-format
+msgid "Failed to read from the file %s, cause: %s"
+msgstr ""
+
+#: src/message.h:78
+#, c-format
+msgid "Failed to calculate SHA1 digest of or a part of the file %s, cause: %s"
+msgstr ""
+
+#: src/message.h:79
+#, c-format
+msgid "Failed to seek the file %s, cause: %s"
+msgstr ""
+
+#: src/message.h:80
+#, c-format
+msgid "The offset is out of range, offset=%lld"
+msgstr ""
+
+#: src/message.h:81
+#, c-format
+msgid "%s is not a directory."
+msgstr ""
+
+#: src/message.h:82
+#, c-format
+msgid "Failed to make the directory %s, cause: %s"
+msgstr ""
+
+#: src/message.h:83
+#, c-format
+msgid "Failed to open the segment file %s, cause: %s"
+msgstr ""
+
+#: src/message.h:84
+#, c-format
+msgid "Failed to write into the segment file %s, cause: %s"
+msgstr ""
+
+#: src/message.h:85
+#, c-format
+msgid "Failed to read from the segment file %s, cause: %s"
+msgstr ""
+
+#: src/message.h:87
+#, c-format
+msgid "Failed to open a socket, cause: %s"
+msgstr ""
+
+#: src/message.h:88
+#, c-format
+msgid "Failed to set a socket option, cause: %s"
+msgstr ""
+
+#: src/message.h:89
+#, c-format
+msgid "Failed to bind a socket, cause: %s"
+msgstr ""
+
+#: src/message.h:90
+#, c-format
+msgid "Failed to listen to a socket, cause: %s"
+msgstr ""
+
+#: src/message.h:91
+#, c-format
+msgid "Failed to accept a peer connection, cause: %s"
+msgstr ""
+
+#: src/message.h:92
+#, c-format
+msgid "Failed to get the name of socket, cause: %s"
+msgstr ""
+
+#: src/message.h:93
+#, c-format
+msgid "Failed to get the name of connected peer, cause: %s"
+msgstr ""
+
+#: src/message.h:94
+#, c-format
+msgid "Failed to resolve the hostname %s, cause: %s"
+msgstr ""
+
+#: src/message.h:95
+#, c-format
+msgid "Failed to connect to the host %s, cause: %s"
+msgstr ""
+
+#: src/message.h:96
+#, c-format
+msgid "Failed to check whether the socket is writable, cause: %s"
+msgstr ""
+
+#: src/message.h:97
+#, c-format
+msgid "Failed to check whether the socket is readable, cause: %s"
+msgstr ""
+
+#: src/message.h:98
+#, c-format
+msgid "Failed to send data, cause: %s"
+msgstr ""
+
+#: src/message.h:99
+#, c-format
+msgid "Failed to receive data, cause: %s"
+msgstr ""
+
+#: src/message.h:100
+#, c-format
+msgid "Failed to peek data, cause: %s"
+msgstr ""
+
 #: src/main.cc:64
 #, c-format
 msgid ""
@@ -336,30 +488,27 @@ msgstr ""
 msgid ""
 " --http-auth-scheme=SCHEME    Set HTTP authentication scheme. Currently, "
 "basic\n"
-"                              is the only supported scheme. You MUST "
-"specify\n"
-"                              this option in order to use HTTP "
-"authentication\n"
-"                              as well as --http-user and --http-passwd."
+"                              is the only supported scheme.\n"
+"                              Default: basic"
 msgstr ""
 
-#: src/main.cc:188
+#: src/main.cc:187
 msgid " --referer=REFERER            Set Referer. This affects to all URLs."
 msgstr ""
 
-#: src/main.cc:189
+#: src/main.cc:188
 msgid ""
 " --ftp-user=USER              Set FTP user. This affects to all URLs.\n"
 "                              Default: anonymous"
 msgstr ""
 
-#: src/main.cc:191
+#: src/main.cc:190
 msgid ""
 " --ftp-passwd=PASSWD          Set FTP password. This affects to all URLs.\n"
 "                              Default: ARIA2USER@"
 msgstr ""
 
-#: src/main.cc:193
+#: src/main.cc:192
 msgid ""
 " --ftp-type=TYPE              Set FTP transfer type. TYPE is either "
 "'binary'\n"
@@ -367,11 +516,11 @@ msgid ""
 "                              Default: binary"
 msgstr ""
 
-#: src/main.cc:196
+#: src/main.cc:195
 msgid " -p, --ftp-pasv               Use passive mode in FTP."
 msgstr ""
 
-#: src/main.cc:197
+#: src/main.cc:196
 msgid ""
 " --ftp-via-http-proxy=METHOD  Use HTTP proxy in FTP. METHOD is either 'get' "
 "or\n"
@@ -379,11 +528,11 @@ msgid ""
 "                              Default: tunnel"
 msgstr ""
 
-#: src/main.cc:201
+#: src/main.cc:200
 msgid " -T, --torrent-file=TORRENT_FILE  The file path to .torrent file."
 msgstr ""
 
-#: src/main.cc:202
+#: src/main.cc:201
 msgid ""
 " --follow-torrent=true|false  Setting this option to false prevents aria2 "
 "to\n"
@@ -392,142 +541,142 @@ msgid ""
 "                              Default: true"
 msgstr ""
 
-#: src/main.cc:206
+#: src/main.cc:205
 msgid ""
 " -S, --show-files             Print the file listing in .torrent file and "
 "exit."
 msgstr ""
 
-#: src/main.cc:207
+#: src/main.cc:206
 msgid ""
 " --direct-file-mapping=true|false Directly read from and write to each file\n"
 "                              mentioned in .torrent file.\n"
 "                              Default: true"
 msgstr ""
 
-#: src/main.cc:210
+#: src/main.cc:209
 msgid ""
 " --listen-port                Set port number to listen to for peer "
 "connection."
 msgstr ""
 
-#: src/main.cc:212
+#: src/main.cc:211
 msgid " -v, --version                Print the version number and exit."
 msgstr ""
 
-#: src/main.cc:213
+#: src/main.cc:212
 msgid " -h, --help                   Print this message and exit."
 msgstr ""
 
-#: src/main.cc:216
+#: src/main.cc:215
 msgid ""
 " You can specify multiple URLs. All URLs must point to the same file\n"
 " or downloading fails."
 msgstr ""
 
-#: src/main.cc:220
+#: src/main.cc:219
 msgid ""
 " Specify files in multi-file torrent to download. Use conjunction with\n"
 " -T option."
 msgstr ""
 
-#: src/main.cc:223
+#: src/main.cc:222
 msgid "Examples:"
 msgstr ""
 
-#: src/main.cc:224
+#: src/main.cc:223
 msgid " Download a file by 1 connection:"
 msgstr ""
 
-#: src/main.cc:226
+#: src/main.cc:225
 msgid " Download a file by 2 connections:"
 msgstr ""
 
-#: src/main.cc:228
+#: src/main.cc:227
 msgid " Download a file by 2 connections, each connects to a different server:"
 msgstr ""
 
-#: src/main.cc:230
+#: src/main.cc:229
 msgid " You can mix up different protocols:"
 msgstr ""
 
-#: src/main.cc:233
+#: src/main.cc:232
 msgid " Download a torrent:"
 msgstr ""
 
-#: src/main.cc:235
+#: src/main.cc:234
 msgid " Download a torrent using local .torrent file:"
 msgstr ""
 
-#: src/main.cc:237
+#: src/main.cc:236
 msgid " Download only selected files:"
 msgstr ""
 
-#: src/main.cc:241
+#: src/main.cc:240
 #, c-format
 msgid "Report bugs to %s"
 msgstr ""
 
-#: src/main.cc:335
+#: src/main.cc:334
 msgid "unrecognized proxy format"
 msgstr ""
 
-#: src/main.cc:362
+#: src/main.cc:361
 msgid "Currently, supported authentication scheme is basic."
 msgstr ""
 
-#: src/main.cc:371
+#: src/main.cc:370
 msgid "retry-wait must be between 0 and 60."
 msgstr ""
 
-#: src/main.cc:388
+#: src/main.cc:387
 msgid "ftp-type must be either 'binary' or 'ascii'."
 msgstr ""
 
-#: src/main.cc:397
+#: src/main.cc:396
 msgid "ftp-via-http-proxy must be either 'get' or 'tunnel'."
 msgstr ""
 
-#: src/main.cc:415
+#: src/main.cc:414
 msgid "min-segment-size invalid"
 msgstr ""
 
-#: src/main.cc:426
+#: src/main.cc:425
 msgid "http-proxy-method must be either 'get' or 'tunnel'."
 msgstr ""
 
-#: src/main.cc:434
+#: src/main.cc:433
 msgid "listen-port must be between 1024 and 65535."
 msgstr ""
 
-#: src/main.cc:445
+#: src/main.cc:444
 msgid "follow-torrent must be either 'true' or 'false'."
 msgstr ""
 
-#: src/main.cc:485
+#: src/main.cc:484
 msgid "split must be between 1 and 5."
 msgstr ""
 
-#: src/main.cc:495
+#: src/main.cc:494
 msgid "timeout must be between 1 and 600"
 msgstr ""
 
-#: src/main.cc:504
+#: src/main.cc:503
 msgid "max-tries invalid"
 msgstr ""
 
-#: src/main.cc:533
+#: src/main.cc:532
 msgid "specify at least one URL"
 msgstr ""
 
-#: src/main.cc:540
+#: src/main.cc:539
 msgid "daemon failed"
 msgstr ""
 
-#: src/main.cc:644
+#: src/main.cc:643
 msgid "Files:"
 msgstr ""
 
-#: src/main.cc:667
+#: src/main.cc:666
 msgid "Errors occurred while binding port.\n"
 msgstr ""

TEMPAT SAMPAH
po/ja.gmo


+ 205 - 55
po/ja.po

@@ -7,8 +7,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: aria2c 0.2.1\n"
 "Report-Msgid-Bugs-To: http://aria2.sourceforge.net/\n"
-"POT-Creation-Date: 2006-04-20 02:49+0900\n"
-"PO-Revision-Date: 2006-04-19 02:03+0900\n"
+"POT-Creation-Date: 2006-04-21 00:25+0900\n"
+"PO-Revision-Date: 2006-04-21 00:42+0900\n"
 "Last-Translator: Tatsuhiro Tsujikawa <tujikawa@rednoah.com>\n"
 "Language-Team: Japanese <ja@li.org>\n"
 "MIME-Version: 1.0\n"
@@ -85,6 +85,21 @@ msgstr ""
 msgid "CUID#%d - Unregistering cuid from segmentManager."
 msgstr "CUID#%d - cuid をセグメントマネジャーから削除します."
 
+#: src/message.h:43
+#, c-format
+msgid "CUID#%d - we got new piece. index=%d"
+msgstr "CUID#%d - 新しいピースを入手しました. index=%d"
+
+#: src/message.h:44
+#, c-format
+msgid "CUID#%d - we got wrong piece. index=%d"
+msgstr "CUID#%d - ピースを入手しましたが, データに誤りがあります. index=%d"
+
+#: src/message.h:46
+#, c-format
+msgid "Tracker returned warning message: %s"
+msgstr "トラッカーが警告メッセージを返しました: %s"
+
 #: src/message.h:48
 #, c-format
 msgid "The segment file %s exists."
@@ -123,7 +138,7 @@ msgstr "chunk 
 
 #: src/message.h:57
 #, c-format
-msgid "Too large chunk. size = %d"
+msgid "Too large chunk. size=%d"
 msgstr "chunk サイズ (%d) が大きすぎます."
 
 #: src/message.h:58
@@ -159,12 +174,12 @@ msgstr "
 
 #: src/message.h:65
 #, c-format
-msgid "The response status is not successful. status = %d"
+msgid "The response status is not successful. status=%d"
 msgstr "レスポンスのステータス (%d) が異常です."
 
 #: src/message.h:66
 #, c-format
-msgid "Too large file size. size = %lld"
+msgid "Too large file size. size=%lld"
 msgstr "ファイルサイズ (%lld) が大きすぎます."
 
 #: src/message.h:67
@@ -181,10 +196,151 @@ msgstr "SSL 
 msgid "Size mismatch %lld != %lld"
 msgstr "サイズが合いません (%lld != %lld)"
 
+#: src/message.h:70
+msgid "Authorization failed."
+msgstr "認証に失敗しました."
+
 #: src/message.h:71
 msgid "Got EOF from the server."
 msgstr "サーバーから EOF を受けとりました."
 
+#: src/message.h:72
+msgid "Got EOF from peer."
+msgstr "ピアから EOF を受け取りました."
+
+#: src/message.h:73
+msgid "Mulformed meta info."
+msgstr "メタ情報ファイルの記述が不正です."
+
+#: src/message.h:75
+#, c-format
+msgid "Failed to open the file %s, cause: %s"
+msgstr "ファイル %s をオープンできませんでした. 原因: %s"
+
+#: src/message.h:76
+#, c-format
+msgid "Failed to write into the file %s, cause: %s"
+msgstr "ファイル %s への書き込みに失敗しました. 原因: %s"
+
+#: src/message.h:77
+#, c-format
+msgid "Failed to read from the file %s, cause: %s"
+msgstr "ファイル %s からの読みとりに失敗しました. 原因: %s"
+
+#: src/message.h:78
+#, c-format
+msgid "Failed to calculate SHA1 digest of or a part of the file %s, cause: %s"
+msgstr ""
+"ファイル %s の (またはその一部の) SHA1 ダイジェストの計算に失敗しました. 原"
+"因: %s"
+
+#: src/message.h:79
+#, c-format
+msgid "Failed to seek the file %s, cause: %s"
+msgstr "ファイル %s のシークに失敗しました. 原因: %s"
+
+#: src/message.h:80
+#, c-format
+msgid "The offset is out of range, offset=%lld"
+msgstr "オフセット (%lld) が範囲外です."
+
+#: src/message.h:81
+#, c-format
+msgid "%s is not a directory."
+msgstr "%s はディレクトリではありません."
+
+#: src/message.h:82
+#, c-format
+msgid "Failed to make the directory %s, cause: %s"
+msgstr "ディレクトリ %s を作成できませんでした. 原因: %s"
+
+#: src/message.h:83
+#, c-format
+msgid "Failed to open the segment file %s, cause: %s"
+msgstr "セグメントファイル %s をオープンできませんでした. 原因: %s"
+
+#: src/message.h:84
+#, c-format
+msgid "Failed to write into the segment file %s, cause: %s"
+msgstr "セグメントファイル %s への書き込みに失敗しました. 原因: %s"
+
+#: src/message.h:85
+#, c-format
+msgid "Failed to read from the segment file %s, cause: %s"
+msgstr "セグメントファイル %s からの読み込みに失敗しました. 原因: %s"
+
+#: src/message.h:87
+#, c-format
+msgid "Failed to open a socket, cause: %s"
+msgstr "ソケットをオープンできませんでした. 原因: %s"
+
+#: src/message.h:88
+#, c-format
+msgid "Failed to set a socket option, cause: %s"
+msgstr "ソケットのオプションの設定に失敗しました. 原因: %s"
+
+#: src/message.h:89
+#, c-format
+msgid "Failed to bind a socket, cause: %s"
+msgstr "ソケットの bind に失敗しました. 原因: %s"
+
+#: src/message.h:90
+#, c-format
+msgid "Failed to listen to a socket, cause: %s"
+msgstr "ソケットの listen に失敗しました. 原因: %s"
+
+#: src/message.h:91
+#, c-format
+msgid "Failed to accept a peer connection, cause: %s"
+msgstr "ピアからの接続の受付に失敗しました. 原因: %s"
+
+#: src/message.h:92
+#, c-format
+msgid "Failed to get the name of socket, cause: %s"
+msgstr "ソケットの名前の取得に失敗しました. 原因: %s"
+
+#: src/message.h:93
+#, c-format
+msgid "Failed to get the name of connected peer, cause: %s"
+msgstr "接続ピアの名前の取得に失敗しました. 原因: %s"
+
+#: src/message.h:94
+#, c-format
+msgid "Failed to resolve the hostname %s, cause: %s"
+msgstr "ホスト名 %s のアドレス解決に失敗しました. 原因: %s"
+
+#: src/message.h:95
+#, c-format
+msgid "Failed to connect to the host %s, cause: %s"
+msgstr "ホスト %s への接続に失敗しました. 原因: %s"
+
+#: src/message.h:96
+#, c-format
+msgid "Failed to check whether the socket is writable, cause: %s"
+msgstr ""
+"ソケットへデータを書き込み可能かどうかのチェックに失敗しました. 原因: %s"
+
+#: src/message.h:97
+#, c-format
+msgid "Failed to check whether the socket is readable, cause: %s"
+msgstr ""
+"ソケットからデータを読みとり可能かどうかのチェックに失敗しました. 原因: %s"
+
+#: src/message.h:98
+#, c-format
+msgid "Failed to send data, cause: %s"
+msgstr "データの送信に失敗しました. 原因: %s"
+
+#: src/message.h:99
+#, c-format
+msgid "Failed to receive data, cause: %s"
+msgstr "データの受信に失敗しました. 原因: %s"
+
+#: src/message.h:100
+#, c-format
+msgid "Failed to peek data, cause: %s"
+msgstr "データの peek に失敗しました. 原因: %s"
+
 #: src/main.cc:64
 #, c-format
 msgid ""
@@ -417,28 +573,22 @@ msgstr ""
 msgid ""
 " --http-auth-scheme=SCHEME    Set HTTP authentication scheme. Currently, "
 "basic\n"
-"                              is the only supported scheme. You MUST "
-"specify\n"
-"                              this option in order to use HTTP "
-"authentication\n"
-"                              as well as --http-user and --http-passwd."
+"                              is the only supported scheme.\n"
+"                              Default: basic"
 msgstr ""
 " --http-auth-scheme=SCHEME    HTTP での認証方法を指定します. 現在サポートされ"
 "て\n"
-"                              いるのは basic です. HTTP 認証を使うには, この"
-"オ\n"
-"                              プションおよび, --http-user, --http-passwd を指"
-"定\n"
-"                              する必要があります."
+"                              いるのは basic です. \n"
+"                              デフォルト値: basic"
 
-#: src/main.cc:188
+#: src/main.cc:187
 msgid " --referer=REFERER            Set Referer. This affects to all URLs."
 msgstr ""
 " --referer=REFERER            リファラーを指定します. このオプションはすべて"
 "の\n"
 "                               URL に影響します."
 
-#: src/main.cc:189
+#: src/main.cc:188
 msgid ""
 " --ftp-user=USER              Set FTP user. This affects to all URLs.\n"
 "                              Default: anonymous"
@@ -448,7 +598,7 @@ msgstr ""
 "                              はすべての URL に影響します.\n"
 "                              デフォルト値: anonymous"
 
-#: src/main.cc:191
+#: src/main.cc:190
 msgid ""
 " --ftp-passwd=PASSWD          Set FTP password. This affects to all URLs.\n"
 "                              Default: ARIA2USER@"
@@ -458,7 +608,7 @@ msgstr ""
 "                              ンはすべての URL に影響します.\n"
 "                              デフォルト値: ARIA2USER@"
 
-#: src/main.cc:193
+#: src/main.cc:192
 msgid ""
 " --ftp-type=TYPE              Set FTP transfer type. TYPE is either "
 "'binary'\n"
@@ -469,11 +619,11 @@ msgstr ""
 "                              'ascii' を指定してください. デフォルト値: "
 "binary"
 
-#: src/main.cc:196
+#: src/main.cc:195
 msgid " -p, --ftp-pasv               Use passive mode in FTP."
 msgstr " -p, --ftp-pasv               FTP で passive モードを使用します."
 
-#: src/main.cc:197
+#: src/main.cc:196
 msgid ""
 " --ftp-via-http-proxy=METHOD  Use HTTP proxy in FTP. METHOD is either 'get' "
 "or\n"
@@ -486,11 +636,11 @@ msgstr ""
 "く\n"
 "                              ださい. デフォルト値: tunnel"
 
-#: src/main.cc:201
+#: src/main.cc:200
 msgid " -T, --torrent-file=TORRENT_FILE  The file path to .torrent file."
 msgstr " -T, --torrent-file=TORRENT_FILE  .torrent ファイルのパスを指定."
 
-#: src/main.cc:202
+#: src/main.cc:201
 msgid ""
 " --follow-torrent=true|false  Setting this option to false prevents aria2 "
 "to\n"
@@ -505,7 +655,7 @@ msgstr ""
 "                              は, BitTorrent モードに入りません.\n"
 "                              デフォルト値: true"
 
-#: src/main.cc:206
+#: src/main.cc:205
 msgid ""
 " -S, --show-files             Print the file listing in .torrent file and "
 "exit."
@@ -514,7 +664,7 @@ msgstr ""
 "し\n"
 "                              終了します."
 
-#: src/main.cc:207
+#: src/main.cc:206
 msgid ""
 " --direct-file-mapping=true|false Directly read from and write to each file\n"
 "                              mentioned in .torrent file.\n"
@@ -525,23 +675,23 @@ msgstr ""
 "                              します.\n"
 "                              デフォルト値: true"
 
-#: src/main.cc:210
+#: src/main.cc:209
 msgid ""
 " --listen-port                Set port number to listen to for peer "
 "connection."
 msgstr ""
 " --listen-port                ピアからの接続を受け付けるポート番号を指定."
 
-#: src/main.cc:212
+#: src/main.cc:211
 msgid " -v, --version                Print the version number and exit."
 msgstr " -v, --version                バージョン番号を表示し, 終了します."
 
-#: src/main.cc:213
+#: src/main.cc:212
 msgid " -h, --help                   Print this message and exit."
 msgstr ""
 " -h, --help                   このヘルプメッセージを表示し, 終了します."
 
-#: src/main.cc:216
+#: src/main.cc:215
 msgid ""
 " You can specify multiple URLs. All URLs must point to the same file\n"
 " or downloading fails."
@@ -550,7 +700,7 @@ msgstr ""
 "れ\n"
 " ばなりません. さもなくばダウンロードは失敗します."
 
-#: src/main.cc:220
+#: src/main.cc:219
 msgid ""
 " Specify files in multi-file torrent to download. Use conjunction with\n"
 " -T option."
@@ -559,103 +709,103 @@ msgstr ""
 "に\n"
 " 使用する."
 
-#: src/main.cc:223
+#: src/main.cc:222
 msgid "Examples:"
 msgstr "例:"
 
-#: src/main.cc:224
+#: src/main.cc:223
 msgid " Download a file by 1 connection:"
 msgstr " 1 コネクションでのダウンロード:"
 
-#: src/main.cc:226
+#: src/main.cc:225
 msgid " Download a file by 2 connections:"
 msgstr " 2 コネクションでのダウンロード:"
 
-#: src/main.cc:228
+#: src/main.cc:227
 msgid " Download a file by 2 connections, each connects to a different server:"
 msgstr " 二つの異なるサーバーに接続してダウンロード:"
 
-#: src/main.cc:230
+#: src/main.cc:229
 msgid " You can mix up different protocols:"
 msgstr " 異なるプロトコルを混合させてダウンロード:"
 
-#: src/main.cc:233
+#: src/main.cc:232
 msgid " Download a torrent:"
 msgstr "torrent をダウンロード:"
 
-#: src/main.cc:235
+#: src/main.cc:234
 msgid " Download a torrent using local .torrent file:"
 msgstr " ローカル .torrent ファイルを使ってダウンロード:"
 
-#: src/main.cc:237
+#: src/main.cc:236
 msgid " Download only selected files:"
 msgstr " ファイルを指定してダウンロード:"
 
-#: src/main.cc:241
+#: src/main.cc:240
 #, c-format
 msgid "Report bugs to %s"
 msgstr "バグレポートはこちらへ: %s"
 
-#: src/main.cc:335
+#: src/main.cc:334
 msgid "unrecognized proxy format"
 msgstr "理解できないProxyフォーマットです."
 
-#: src/main.cc:362
+#: src/main.cc:361
 msgid "Currently, supported authentication scheme is basic."
 msgstr "現在サポートされている認証方法は basic です."
 
-#: src/main.cc:371
+#: src/main.cc:370
 msgid "retry-wait must be between 0 and 60."
 msgstr "retry-wait は 0 から 60 の間で指定してください."
 
-#: src/main.cc:388
+#: src/main.cc:387
 msgid "ftp-type must be either 'binary' or 'ascii'."
 msgstr "ftp-type は 'binary' または 'ascii' を指定してください."
 
-#: src/main.cc:397
+#: src/main.cc:396
 msgid "ftp-via-http-proxy must be either 'get' or 'tunnel'."
 msgstr "ftp-via-http-proxy は 'get' または 'tunnel' を指定してください."
 
-#: src/main.cc:415
+#: src/main.cc:414
 msgid "min-segment-size invalid"
 msgstr "min-segment-size が不正です."
 
-#: src/main.cc:426
+#: src/main.cc:425
 msgid "http-proxy-method must be either 'get' or 'tunnel'."
 msgstr "http-proxy-method は 'get' または 'tunnel' を指定してください."
 
-#: src/main.cc:434
+#: src/main.cc:433
 msgid "listen-port must be between 1024 and 65535."
 msgstr "listen-port は 1024 - 65535 の値を指定してください."
 
-#: src/main.cc:445
+#: src/main.cc:444
 msgid "follow-torrent must be either 'true' or 'false'."
 msgstr "follow-torrent は 'true' または 'false を指定してください."
 
-#: src/main.cc:485
+#: src/main.cc:484
 msgid "split must be between 1 and 5."
 msgstr "split は 1 - 5 の値を指定してください."
 
-#: src/main.cc:495
+#: src/main.cc:494
 msgid "timeout must be between 1 and 600"
 msgstr "timeout は 1 - 600 の値を指定してください."
 
-#: src/main.cc:504
+#: src/main.cc:503
 msgid "max-tries invalid"
 msgstr "max-tries が不正です."
 
-#: src/main.cc:533
+#: src/main.cc:532
 msgid "specify at least one URL"
 msgstr "一個以上の URL を指定してください."
 
-#: src/main.cc:540
+#: src/main.cc:539
 msgid "daemon failed"
 msgstr "デーモン起動に失敗"
 
-#: src/main.cc:644
+#: src/main.cc:643
 msgid "Files:"
 msgstr "ファイル:"
 
-#: src/main.cc:667
+#: src/main.cc:666
 msgid "Errors occurred while binding port.\n"
 msgstr "ポートをバインド中にエラーが発生しました.\n"

+ 8 - 6
src/AbstractDiskWriter.cc

@@ -60,6 +60,7 @@ void AbstractDiskWriter::closeFile() {
 }
 
 void AbstractDiskWriter::openExistingFile(const string& filename) {
+  this->filename = filename;
   File f(filename);
   if(!f.isFile()) {
     throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), "file not found");
@@ -71,6 +72,7 @@ void AbstractDiskWriter::openExistingFile(const string& filename) {
 }
 
 void AbstractDiskWriter::createFile(const string& filename, int addFlags) {
+  this->filename = filename;
   // TODO proper filename handling needed
   assert(filename.size());
 //   if(filename.empty()) {
@@ -83,14 +85,14 @@ void AbstractDiskWriter::createFile(const string& filename, int addFlags) {
 
 void AbstractDiskWriter::writeDataInternal(const char* data, int len) {
   if(write(fd, data, len) < 0) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_FILE_WRITE, filename.c_str(), strerror(errno));
   }
 }
 
 int AbstractDiskWriter::readDataInternal(char* data, int len) {
   int ret;
   if((ret = read(fd, data, len)) < 0) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_FILE_READ, filename.c_str(), strerror(errno));
   }
   return ret;
 }
@@ -103,7 +105,7 @@ string AbstractDiskWriter::sha1Sum(long long int offset, long long int length) {
     char buf[BUFSIZE];
     for(int i = 0; i < length/BUFSIZE; i++) {
       if(BUFSIZE != readData(buf, BUFSIZE, offset)) {
-	throw "error";
+	throw string("error");
       }
       sha1DigestUpdate(ctx, buf, BUFSIZE);
       offset += BUFSIZE;
@@ -111,7 +113,7 @@ string AbstractDiskWriter::sha1Sum(long long int offset, long long int length) {
     int r = length%BUFSIZE;
     if(r > 0) {
       if(r != readData(buf, r, offset)) {
-	throw "error";
+	throw string("error");
       }
       sha1DigestUpdate(ctx, buf, r);
     }
@@ -119,7 +121,7 @@ string AbstractDiskWriter::sha1Sum(long long int offset, long long int length) {
     sha1DigestFinal(ctx, hashValue);
     return Util::toHex(hashValue, 20);
   } catch(string ex) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_FILE_SHA1SUM, filename.c_str(), strerror(errno));
   }
 #else
   return "";
@@ -128,7 +130,7 @@ string AbstractDiskWriter::sha1Sum(long long int offset, long long int length) {
 
 void AbstractDiskWriter::seek(long long int offset) {
   if(offset != lseek(fd, offset, SEEK_SET)) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_FILE_SEEK, filename.c_str(), strerror(errno));
   }
 }
 

+ 1 - 1
src/AbstractDiskWriter.h

@@ -29,8 +29,8 @@
 
 class AbstractDiskWriter:public DiskWriter {
 protected:
+  string filename;
   int fd;
-
 #ifdef ENABLE_SHA1DIGEST
   MessageDigestContext ctx;
 #endif // ENABLE_SHA1DIGEST

+ 3 - 3
src/Directory.cc

@@ -22,6 +22,7 @@
 #include "Directory.h"
 #include "File.h"
 #include "DlAbortEx.h"
+#include "message.h"
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -39,12 +40,11 @@ void Directory::createDir(const string& parentDir, bool recursive) const {
   File f(path);
   if(f.exists()) {
     if(!f.isDir()) {
-      throw new DlAbortEx("%s is already exists and it is not a directory.",
-			  path.c_str());
+      throw new DlAbortEx(EX_NOT_DIRECTORY, path.c_str());
     }
   } else {
     if(mkdir(path.c_str(), S_IRUSR|S_IWUSR|S_IXUSR) == -1) {
-      throw new DlAbortEx(strerror(errno));
+      throw new DlAbortEx(EX_MAKE_DIR, path.c_str(), strerror(errno));
     }
   }
   if(recursive) {

+ 9 - 10
src/MultiDiskWriter.cc

@@ -22,6 +22,7 @@
 #include "MultiDiskWriter.h"
 #include "DlAbortEx.h"
 #include "Util.h"
+#include "message.h"
 #include <errno.h>
 
 MultiDiskWriter::MultiDiskWriter(int pieceLength):pieceLength(pieceLength) {
@@ -82,8 +83,7 @@ void MultiDiskWriter::openExistingFile(const string& filename) {
   }
 }
 
-void MultiDiskWriter::writeData(const char* data, int len, long long int position) {
-  long long int offset = position;
+void MultiDiskWriter::writeData(const char* data, int len, long long int offset) {
   long long int fileOffset = offset;
   bool writing = false;
   int rem = len;
@@ -100,7 +100,7 @@ void MultiDiskWriter::writeData(const char* data, int len, long long int positio
     }
   }
   if(!writing) {
-    throw new DlAbortEx("offset out of range");
+    throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, offset);
   }
 }
 
@@ -119,8 +119,7 @@ int MultiDiskWriter::calculateLength(const DiskWriterEntry* entry, long long int
   return length;
 }
 
-int MultiDiskWriter::readData(char* data, int len, long long int position) {
-  long long int offset = position;
+int MultiDiskWriter::readData(char* data, int len, long long int offset) {
   long long int fileOffset = offset;
   bool reading = false;
   int rem = len;
@@ -138,7 +137,7 @@ int MultiDiskWriter::readData(char* data, int len, long long int position) {
     }
   }
   if(!reading) {
-    throw new DlAbortEx("offset out of range");
+    throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, offset);
   }
   return totalReadLength;
 }
@@ -149,7 +148,7 @@ void MultiDiskWriter::hashUpdate(const DiskWriterEntry* entry, long long int off
   char buf[BUFSIZE];
   for(int i = 0; i < length/BUFSIZE; i++) {
     if(BUFSIZE != entry->diskWriter->readData(buf, BUFSIZE, offset)) {
-      throw "error";
+      throw string("error");
     }
     sha1DigestUpdate(ctx, buf, BUFSIZE);
     offset += BUFSIZE;
@@ -157,7 +156,7 @@ void MultiDiskWriter::hashUpdate(const DiskWriterEntry* entry, long long int off
   int r = length%BUFSIZE;
   if(r > 0) {
     if(r != entry->diskWriter->readData(buf, r, offset)) {
-      throw "error";
+      throw string("error");
     }
     sha1DigestUpdate(ctx, buf, r);
   }
@@ -184,13 +183,13 @@ string MultiDiskWriter::sha1Sum(long long int offset, long long int length) {
       }
     }
     if(!reading) {
-      throw new DlAbortEx("offset out of range");
+      throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, offset);
     }
     unsigned char hashValue[20];
     sha1DigestFinal(ctx, hashValue);
     return Util::toHex(hashValue, 20);
   } catch(string ex) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_FILE_SHA1SUM, "", strerror(errno));
   }
 #else
   return "";

+ 3 - 2
src/PreAllocationDiskWriter.cc

@@ -21,6 +21,7 @@
 /* copyright --> */
 #include "PreAllocationDiskWriter.h"
 #include "DlAbortEx.h"
+#include "message.h"
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -43,13 +44,13 @@ void PreAllocationDiskWriter::initAndOpenFile(const string& filename) {
   int r = totalLength%bufSize;
   for(long long int i = 0; i < x; i++) {
     if(write(fd, buf, bufSize) < 0) {
-      throw new DlAbortEx(strerror(errno));
+      throw new DlAbortEx(EX_FILE_WRITE, filename.c_str(), strerror(errno));
     }
   }
   if(r > 0) {
     seek(totalLength-r);
     if(write(fd, buf, r) < 0) {
-	throw new DlAbortEx(strerror(errno));
+	throw new DlAbortEx(EX_FILE_WRITE, filename.c_str(), strerror(errno));
     }
   }
 }

+ 26 - 13
src/SegmentMan.cc

@@ -122,8 +122,14 @@ void SegmentMan::load() {
   string segFilename = getSegmentFilePath();
   logger->info(MSG_LOADING_SEGMENT_FILE, segFilename.c_str());
   FILE* segFile = openSegFile(segFilename, "r+");
-  read(segFile);
-  fclose(segFile);
+  try {
+    read(segFile);
+    fclose(segFile);
+  } catch(string ex) {
+    fclose(segFile);
+    throw new DlAbortEx(EX_SEGMENT_FILE_READ,
+			segFilename.c_str(), strerror(errno));
+  }
   logger->info(MSG_LOADED_SEGMENT_FILE);
   for(Segments::iterator itr = segments.begin(); itr != segments.end();
       itr++) {
@@ -138,22 +144,29 @@ void SegmentMan::save() const {
   string segFilename = getSegmentFilePath();
   logger->info(MSG_SAVING_SEGMENT_FILE, segFilename.c_str());
   FILE* segFile = openSegFile(segFilename, "w");
-  if(fwrite(&totalSize, sizeof(totalSize), 1, segFile) < 1) {
-    throw new DlAbortEx(strerror(errno));
-  }
-  for(Segments::const_iterator itr = segments.begin(); itr != segments.end(); itr++) {
-    if(fwrite(&*itr, sizeof(Segment), 1, segFile) < 1) {
-      throw new DlAbortEx(strerror(errno));
+  try {
+    if(fwrite(&totalSize, sizeof(totalSize), 1, segFile) < 1) {
+      throw string("writeError");
+    }
+    for(Segments::const_iterator itr = segments.begin(); itr != segments.end(); itr++) {
+      if(fwrite(&*itr, sizeof(Segment), 1, segFile) < 1) {
+	throw string("writeError");
+      }
     }
+    fclose(segFile);
+    logger->info(MSG_SAVED_SEGMENT_FILE);
+  } catch(string ex) {
+    fclose(segFile);
+    throw new DlAbortEx(EX_SEGMENT_FILE_WRITE,
+			segFilename.c_str(), strerror(errno));
   }
-  fclose(segFile);
-  logger->info(MSG_SAVED_SEGMENT_FILE);
 }
 
 FILE* SegmentMan::openSegFile(const string& segFilename, const string& mode) const {
   FILE* segFile = fopen(segFilename.c_str(), mode.c_str());
   if(segFile == NULL) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SEGMENT_FILE_OPEN,
+			segFilename.c_str(), strerror(errno));
   }
   return segFile;
 }
@@ -161,13 +174,13 @@ FILE* SegmentMan::openSegFile(const string& segFilename, const string& mode) con
 void SegmentMan::read(FILE* file) {
   assert(file != NULL);
   if(fread(&totalSize, sizeof(totalSize), 1, file) < 1) {
-    throw new DlAbortEx(strerror(errno));
+    throw string("readError");
   }
   while(1) {
     Segment seg;
     if(fread(&seg, sizeof(Segment), 1, file) < 1) {
       if(ferror(file)) {
-	throw new DlAbortEx(strerror(errno));
+	throw string("readError");
       } else if(feof(file)) {
 	break;
       }

+ 22 - 21
src/SocketCore.cc

@@ -20,6 +20,9 @@
  */
 /* copyright --> */
 #include "SocketCore.h"
+#include "DlRetryEx.h"
+#include "DlAbortEx.h"
+#include "message.h"
 #include <unistd.h>
 #include <fcntl.h>
 #include <netdb.h>
@@ -29,10 +32,7 @@
 #include <arpa/inet.h>
 #include <sys/time.h>
 #include <netdb.h>
-#include "DlRetryEx.h"
-#include "DlAbortEx.h"
 #include <errno.h>
-#include "message.h"
 
 SocketCore::SocketCore():sockfd(-1) {
   init();
@@ -71,13 +71,13 @@ void SocketCore::beginListen(int port) {
   //sockfd = socket(AF_UNSPEC, SOCK_STREAM, PF_UNSPEC);
   sockfd = socket(AF_INET, SOCK_STREAM, 0);
   if(sockfd == -1) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SOCKET_OPEN, strerror(errno));
   }
   socklen_t sockopt = 1;
   if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(socklen_t)) < 0) {
     close(sockfd);
     sockfd = -1;
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SOCKET_SET_OPT, strerror(errno));
   }
 
   struct sockaddr_in sockaddr;
@@ -87,11 +87,11 @@ void SocketCore::beginListen(int port) {
   sockaddr.sin_port = htons(port);
   
   if(bind(sockfd, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == -1) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SOCKET_BIND, strerror(errno));
   }
 
   if(listen(sockfd, 1) == -1) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SOCKET_LISTEN, strerror(errno));
   }
 }
 
@@ -101,7 +101,7 @@ SocketCore* SocketCore::acceptConnection() const {
   memset((char*)&sockaddr, 0, sizeof(sockaddr));
   int fd;
   if((fd = accept(sockfd, (struct sockaddr*)&sockaddr, &len)) == -1) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SOCKET_ACCEPT, strerror(errno));
   }
 
   SocketCore* s = new SocketCore(fd);
@@ -113,7 +113,7 @@ void SocketCore::getAddrInfo(pair<string, int>& addrinfo) const {
   memset((char*)&listenaddr, 0, sizeof(listenaddr));
   socklen_t len = sizeof(listenaddr);
   if(getsockname(sockfd, (struct sockaddr*)&listenaddr, &len) == -1) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SOCKET_GET_NAME, strerror(errno));
   }
   addrinfo.first = inet_ntoa(listenaddr.sin_addr);
   addrinfo.second = ntohs(listenaddr.sin_port);
@@ -124,7 +124,7 @@ void SocketCore::getPeerInfo(pair<string, int>& peerinfo) const {
   memset(&peerin, 0, sizeof(peerin));
   int len = sizeof(peerin);
   if(getpeername(sockfd, (struct sockaddr*)&peerin, (socklen_t*)&len) < 0) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SOCKET_GET_PEER, strerror(errno));
   }
   peerinfo.first = inet_ntoa(peerin.sin_addr);
   peerinfo.second = ntohs(peerin.sin_port);
@@ -134,13 +134,13 @@ void SocketCore::establishConnection(const string& host, int port) {
   closeConnection();
   sockfd = socket(AF_INET, SOCK_STREAM, 0);
   if(sockfd == -1) {
-      throw new DlAbortEx(strerror(errno));
+      throw new DlAbortEx(EX_SOCKET_OPEN, strerror(errno));
   }
   socklen_t sockopt = 1;
   if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(socklen_t)) < 0) {
     close(sockfd);
     sockfd = -1;
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SOCKET_SET_OPT, strerror(errno));
   }
 
   struct sockaddr_in sockaddr;
@@ -159,7 +159,8 @@ void SocketCore::establishConnection(const string& host, int port) {
     struct addrinfo* res;
     int ec;
     if((ec = getaddrinfo(host.c_str(), NULL, &ai, &res)) != 0) {
-      throw new DlAbortEx(gai_strerror(ec));
+      throw new DlAbortEx(EX_RESOLVE_HOSTNAME,
+			  host.c_str(), gai_strerror(ec));
     }
     sockaddr.sin_addr = ((struct sockaddr_in*)res->ai_addr)->sin_addr;
     freeaddrinfo(res);
@@ -168,7 +169,7 @@ void SocketCore::establishConnection(const string& host, int port) {
   int flags = fcntl(sockfd, F_GETFL, 0);
   fcntl(sockfd, F_SETFL, flags|O_NONBLOCK);
   if(connect(sockfd, (struct sockaddr*)&sockaddr, (socklen_t)sizeof(sockaddr)) == -1 && errno != EINPROGRESS) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SOCKET_CONNECT, host.c_str(), strerror(errno));
   }
 }
 
@@ -227,7 +228,7 @@ bool SocketCore::isWritable(int timeout) const {
     if(errno == EINPROGRESS) {
       return false;
     } else {
-      throw new DlRetryEx(strerror(errno));
+      throw new DlRetryEx(EX_SOCKET_CHECK_WRITABLE, strerror(errno));
     }
   }
 }
@@ -256,7 +257,7 @@ bool SocketCore::isReadable(int timeout) const {
     if(errno == EINPROGRESS) {
       return false;
     } else {
-      throw new DlRetryEx(strerror(errno));
+      throw new DlRetryEx(EX_SOCKET_CHECK_READABLE, strerror(errno));
     }
   }
 }
@@ -283,7 +284,7 @@ void SocketCore::writeData(const char* data, int len, int timeout) {
 #else // HAVE_LIBGNUTLS
     errorMsg = strerror(errno);
 #endif
-    throw new DlRetryEx(errorMsg);
+    throw new DlRetryEx(EX_SOCKET_SEND, errorMsg);
   }
 }
 
@@ -309,7 +310,7 @@ void SocketCore::readData(char* data, int& len, int timeout) {
 #else // HAVE_LIBGNUTLS
     errorMsg = strerror(errno);
 #endif
-    throw new DlRetryEx(errorMsg);
+    throw new DlRetryEx(EX_SOCKET_RECV, errorMsg);
   }
   len = ret;
 }
@@ -336,7 +337,7 @@ void SocketCore::peekData(char* data, int& len, int timeout) {
 #else // HAVE_LIBGNUTLS
     errorMsg = strerror(errno);
 #endif
-    throw new DlRetryEx(errorMsg);
+    throw new DlRetryEx(EX_SOCKET_PEEK, errorMsg);
   }
   len = ret;
 }
@@ -377,7 +378,7 @@ int SocketCore::gnutlsRecv(char* data, int len) {
   if(plen < len) {
     int ret = gnutls_record_recv(sslSession, data+plen, len-plen);
     if(ret < 0) {
-      throw new DlRetryEx(gnutls_strerror(ret));
+      throw new DlRetryEx(EX_SOCKET_RECV, gnutls_strerror(ret));
     }
     return plen+ret;
   } else {
@@ -393,7 +394,7 @@ int SocketCore::gnutlsPeek(char* data, int len) {
     memcpy(data, peekBuf, peekBufLength);
     int ret = gnutls_record_recv(sslSession, data+peekBufLength, len-peekBufLength);
     if(ret < 0) {
-      throw new DlRetryEx(gnutls_strerror(ret));
+      throw new DlRetryEx(EX_SOCKET_PEEK, gnutls_strerror(ret));
     }
     addPeekData(data+peekBufLength, ret);
     return peekBufLength;

+ 37 - 24
src/TorrentMan.cc

@@ -376,7 +376,7 @@ void TorrentMan::setup(const string& metaInfoFile, const Strings& targetFilePath
   pieces = totalLength/pieceLength+(totalLength%pieceLength ? 1 : 0);
   Data* piecesHashData = (Data*)infoDic->get("pieces");
   if(piecesHashData->getLen() != pieces*20) {
-    throw new DlAbortEx("the number of pieces is wrong.");
+    throw new DlAbortEx("The number of pieces is wrong.");
   }
   for(int index = 0; index < pieces; index++) {
     string hex = Util::toHex((unsigned char*)&piecesHashData->getData()[index*20], 20);
@@ -418,7 +418,7 @@ void TorrentMan::setFileFilter(const Strings& filePaths) {
   for(Strings::const_iterator pitr = filePaths.begin();
       pitr != filePaths.end(); pitr++) {
     if(!diskAdaptor->addDownloadEntry(*pitr)) {
-      throw new DlAbortEx("no such file entry <%s>", (*pitr).c_str());
+      throw new DlAbortEx("No such file entry %s", (*pitr).c_str());
     }
     FileEntry fileEntry = diskAdaptor->getFileEntryFromPath(*pitr);
     bitfield->addFilter(fileEntry.offset, fileEntry.length);
@@ -469,7 +469,8 @@ bool TorrentMan::segmentFileExists() const {
 FILE* TorrentMan::openSegFile(const string& segFilename, const string& mode) const {
   FILE* segFile = fopen(segFilename.c_str(), mode.c_str());
   if(segFile == NULL) {
-    throw new DlAbortEx(strerror(errno));
+    throw new DlAbortEx(EX_SEGMENT_FILE_OPEN,
+			segFilename.c_str(), strerror(errno));
   }
   return segFile;
 }
@@ -478,8 +479,14 @@ void TorrentMan::load() {
   string segFilename = getSegmentFilePath();
   logger->info(MSG_LOADING_SEGMENT_FILE, segFilename.c_str());
   FILE* segFile = openSegFile(segFilename, "r+");
-  read(segFile);
-  fclose(segFile);
+  try {
+    read(segFile);
+    fclose(segFile);
+  } catch(string ex) {
+    fclose(segFile);
+    throw new DlAbortEx(EX_SEGMENT_FILE_READ,
+			segFilename.c_str(), strerror(errno));
+  }
   logger->info(MSG_LOADED_SEGMENT_FILE);
 }
 
@@ -487,27 +494,27 @@ void TorrentMan::read(FILE* file) {
   assert(file != NULL);
   unsigned char savedInfoHash[INFO_HASH_LENGTH];
   if(fread(savedInfoHash, INFO_HASH_LENGTH, 1, file) < 1) {
-    throw new DlAbortEx(strerror(errno));
+    throw string("readError");
   }
   if(Util::toHex(savedInfoHash, INFO_HASH_LENGTH) != Util::toHex(infoHash, INFO_HASH_LENGTH)) {
-    throw new DlAbortEx("info hash mismatch");
+    throw new DlAbortEx("Incorrect infoHash.");
   }
   unsigned char* savedBitfield = new unsigned char[bitfield->getBitfieldLength()];
   try {
     if(fread(savedBitfield, bitfield->getBitfieldLength(), 1, file) < 1) {
-      throw new DlAbortEx(strerror(errno));
+      throw string("readError");
     }
     setBitfield(savedBitfield, bitfield->getBitfieldLength());
     if(fread(&downloadLength, sizeof(downloadLength), 1, file) < 1) {
-      throw new DlAbortEx(strerror(errno));
+      throw string("readError");
     }
     if(fread(&uploadLength, sizeof(uploadLength), 1, file) < 1) {
-      throw new DlAbortEx(strerror(errno));
+      throw string("readError");
     }
     preDownloadLength = downloadLength;
     preUploadLength = uploadLength;
     delete [] savedBitfield;
-  } catch(Exception* ex) {
+  } catch(...) {
     delete [] savedBitfield;
     throw;
   }
@@ -520,20 +527,26 @@ void TorrentMan::save() const {
   string segFilename = getSegmentFilePath();
   logger->info(MSG_SAVING_SEGMENT_FILE, segFilename.c_str());
   FILE* file = openSegFile(segFilename, "w");
-  if(fwrite(infoHash, INFO_HASH_LENGTH, 1, file) < 1) {
-    throw new DlAbortEx(strerror(errno));
-  }
-  if(fwrite(bitfield->getBitfield(), bitfield->getBitfieldLength(), 1, file) < 1) {
-    throw new DlAbortEx(strerror(errno));
-  }
-  if(fwrite(&downloadLength, sizeof(downloadLength), 1, file) < 1) {
-    throw new DlAbortEx(strerror(errno));
-  }
-  if(fwrite(&uploadLength, sizeof(uploadLength), 1, file) < 1) {
-    throw new DlAbortEx(strerror(errno));
+  try {
+    if(fwrite(infoHash, INFO_HASH_LENGTH, 1, file) < 1) {
+      throw string("writeError");
+    }
+    if(fwrite(bitfield->getBitfield(), bitfield->getBitfieldLength(), 1, file) < 1) {
+      throw string("writeError");
+    }
+    if(fwrite(&downloadLength, sizeof(downloadLength), 1, file) < 1) {
+      throw string("writeError");
+    }
+    if(fwrite(&uploadLength, sizeof(uploadLength), 1, file) < 1) {
+      throw string("writeError");
+    }
+    fclose(file);
+    logger->info(MSG_SAVED_SEGMENT_FILE);
+  } catch(string ex) {
+    fclose(file);
+    throw new DlAbortEx(EX_SEGMENT_FILE_WRITE,
+			segFilename.c_str(), strerror(errno));
   }
-  fclose(file);
-  logger->info(MSG_SAVED_SEGMENT_FILE);
 }
 
 void TorrentMan::remove() const {

+ 1 - 1
src/TrackerWatcherCommand.cc

@@ -32,7 +32,7 @@ TrackerWatcherCommand::TrackerWatcherCommand(int cuid,
 TrackerWatcherCommand::~TrackerWatcherCommand() {}
 
 bool TrackerWatcherCommand::execute() {
-  if(e->torrentMan->trackers == 0 && e->torrentMan->connections < 30) {
+  if(e->torrentMan->trackers == 0 && e->torrentMan->connections < MIN_PEERS) {
     e->torrentMan->req->resetTryCount();
     
     if(e->torrentMan->downloadComplete()) {

+ 2 - 0
src/TrackerWatcherCommand.h

@@ -25,6 +25,8 @@
 #include "Command.h"
 #include "TorrentDownloadEngine.h"
 
+#define MIN_PEERS 15
+
 class TrackerWatcherCommand : public Command {
 private:
   TorrentDownloadEngine* e;

+ 8 - 7
src/Util.cc

@@ -22,6 +22,7 @@
 #include "Util.h"
 #include "DlAbortEx.h"
 #include "File.h"
+#include "message.h"
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -210,32 +211,32 @@ void Util::rangedFileCopy(const string& dest, const string& src, long long int s
   int srcFd = -1;
   try {
     if((destFd = open(dest.c_str(), O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IWUSR)) == -1) {
-      throw new DlAbortEx(strerror(errno));
+      throw new DlAbortEx(EX_FILE_OPEN, dest.c_str(), strerror(errno));
     }
     if((srcFd = open(src.c_str(), O_RDONLY, S_IRUSR|S_IWUSR)) == -1) {
-      throw new DlAbortEx(strerror(errno));
+      throw new DlAbortEx(EX_FILE_OPEN, src.c_str(), strerror(errno));
     }
     if(lseek(srcFd, srcOffset, SEEK_SET) != srcOffset) {
-      throw new DlAbortEx(strerror(errno));
+      throw new DlAbortEx(EX_FILE_SEEK, src.c_str(), strerror(errno));
     }
     int x = length/bufSize;
     int r = length%bufSize;
     for(int i = 0; i < x; i++) {
       int readLength;
       if((readLength = read(srcFd, buf, bufSize)) == -1 || readLength != bufSize) {
-	throw new DlAbortEx(strerror(errno));
+	throw new DlAbortEx(EX_FILE_READ, src.c_str(), strerror(errno));
       }
       if(write(destFd, buf, readLength) == -1) {
-	throw new DlAbortEx(strerror(errno));
+	throw new DlAbortEx(EX_FILE_WRITE, dest.c_str(), strerror(errno));
       }
     }
     if(r > 0) {
       int readLength;
       if((readLength = read(srcFd, buf, r)) == -1 || readLength != r) {
-	throw new DlAbortEx(strerror(errno));
+	throw new DlAbortEx(EX_FILE_READ, src.c_str(), strerror(errno));
       }
       if(write(destFd, buf, r) == -1) {
-	throw new DlAbortEx(strerror(errno));
+	throw new DlAbortEx(EX_FILE_WRITE, dest.c_str(), strerror(errno));
       }
     }
     close(srcFd);

+ 2 - 3
src/main.cc

@@ -182,9 +182,8 @@ void showUsage() {
 	    "                              METHOD is either 'get' or 'tunnel'.\n"
 	    "                              Default: tunnel") << endl;
   cout << _(" --http-auth-scheme=SCHEME    Set HTTP authentication scheme. Currently, basic\n"
-	    "                              is the only supported scheme. You MUST specify\n"
-	    "                              this option in order to use HTTP authentication\n"
-	    "                              as well as --http-user and --http-passwd.") << endl;
+	    "                              is the only supported scheme.\n"
+	    "                              Default: basic") << endl;
   cout << _(" --referer=REFERER            Set Referer. This affects to all URLs.") << endl;
   cout << _(" --ftp-user=USER              Set FTP user. This affects to all URLs.\n"
 	    "                              Default: anonymous") << endl;

+ 35 - 10
src/message.h

@@ -40,10 +40,10 @@
 #define MSG_SEND_PEER_MESSAGE_WITH_BITFIELD "CUID#%d - To: %s:%d %s %s"
 #define MSG_SEND_PEER_MESSAGE_WITH_INDEX_BEGIN_LENGTH "CUID#%d - To: %s:%d %s index=%d, begin=%d, length=%d"
 #define MSG_RECEIVE_PEER_MESSAGE "CUID#%d - From: %s:%d %s"
-#define MSG_GOT_NEW_PIECE "CUID#%d - we got new piece. index=%d"
-#define MSG_GOT_WRONG_PIECE "CUID#%d - we got wrong piece. index=%d"
+#define MSG_GOT_NEW_PIECE _("CUID#%d - we got new piece. index=%d")
+#define MSG_GOT_WRONG_PIECE _("CUID#%d - we got wrong piece. index=%d")
 
-#define MSG_TRACKER_WARNING_MESSAGE "Tracker returned warning message: %s"
+#define MSG_TRACKER_WARNING_MESSAGE _("Tracker returned warning message: %s")
 
 #define MSG_SEGMENT_FILE_EXISTS _("The segment file %s exists.")
 #define MSG_SEGMENT_FILE_DOES_NOT_EXIST _("The segment file %s does not exist.")
@@ -54,7 +54,7 @@
 
 #define EX_TIME_OUT _("Timeout.")
 #define EX_INVALID_CHUNK_SIZE _("Invalid chunk size.")
-#define EX_TOO_LARGE_CHUNK _("Too large chunk. size = %d")
+#define EX_TOO_LARGE_CHUNK _("Too large chunk. size=%d")
 #define EX_INVALID_HEADER _("Invalid header.")
 #define EX_INVALID_RESPONSE _("Invalid response.")
 #define EX_NO_HEADER _("No header found.")
@@ -62,16 +62,41 @@
 #define EX_PROXY_CONNECTION_FAILED _("Proxy connection failed.")
 #define EX_CONNECTION_FAILED _("Connection failed.")
 #define EX_FILENAME_MISMATCH _("The requested filename and the previously registered one are not same. %s != %s")
-#define EX_BAD_STATUS _("The response status is not successful. status = %d")
-#define EX_TOO_LARGE_FILE _("Too large file size. size = %lld")
+#define EX_BAD_STATUS _("The response status is not successful. status=%d")
+#define EX_TOO_LARGE_FILE _("Too large file size. size=%lld")
 #define EX_TRANSFER_ENCODING_NOT_SUPPORTED _("Transfer encoding %s is not supported.")
 #define EX_SSL_INIT_FAILURE _("SSL initialization failed.")
 #define EX_SIZE_MISMATCH _("Size mismatch %lld != %lld")
-#define EX_AUTH_FAILED "Authorization failed."
+#define EX_AUTH_FAILED _("Authorization failed.")
 #define EX_GOT_EOF _("Got EOF from the server.")
-#define EX_EOF_FROM_PEER "Got EOF from peer."
-#define EX_MULFORMED_META_INFO "Mulformed meta info."
+#define EX_EOF_FROM_PEER _("Got EOF from peer.")
+#define EX_MULFORMED_META_INFO _("Mulformed meta info.")
 
-#define EX_FILE_OPEN "Error occurred while opening <%s>, cause: %s"
+#define EX_FILE_OPEN _("Failed to open the file %s, cause: %s")
+#define EX_FILE_WRITE _("Failed to write into the file %s, cause: %s")
+#define EX_FILE_READ _("Failed to read from the file %s, cause: %s")
+#define EX_FILE_SHA1SUM _("Failed to calculate SHA1 digest of or a part of the file %s, cause: %s")
+#define EX_FILE_SEEK _("Failed to seek the file %s, cause: %s")
+#define EX_FILE_OFFSET_OUT_OF_RANGE _("The offset is out of range, offset=%lld")
+#define EX_NOT_DIRECTORY _("%s is not a directory.")
+#define EX_MAKE_DIR _("Failed to make the directory %s, cause: %s")
+#define EX_SEGMENT_FILE_OPEN _("Failed to open the segment file %s, cause: %s")
+#define EX_SEGMENT_FILE_WRITE _("Failed to write into the segment file %s, cause: %s")
+#define EX_SEGMENT_FILE_READ _("Failed to read from the segment file %s, cause: %s")
+
+#define EX_SOCKET_OPEN _("Failed to open a socket, cause: %s")
+#define EX_SOCKET_SET_OPT _("Failed to set a socket option, cause: %s")
+#define EX_SOCKET_BIND _("Failed to bind a socket, cause: %s")
+#define EX_SOCKET_LISTEN _("Failed to listen to a socket, cause: %s")
+#define EX_SOCKET_ACCEPT _("Failed to accept a peer connection, cause: %s")
+#define EX_SOCKET_GET_NAME _("Failed to get the name of socket, cause: %s")
+#define EX_SOCKET_GET_PEER _("Failed to get the name of connected peer, cause: %s")
+#define EX_RESOLVE_HOSTNAME _("Failed to resolve the hostname %s, cause: %s")
+#define EX_SOCKET_CONNECT _("Failed to connect to the host %s, cause: %s")
+#define EX_SOCKET_CHECK_WRITABLE _("Failed to check whether the socket is writable, cause: %s")
+#define EX_SOCKET_CHECK_READABLE _("Failed to check whether the socket is readable, cause: %s")
+#define EX_SOCKET_SEND _("Failed to send data, cause: %s")
+#define EX_SOCKET_RECV _("Failed to receive data, cause: %s")
+#define EX_SOCKET_PEEK _("Failed to peek data, cause: %s")
 
 #endif // _D_MESSAGE_H_