mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 14:12:31 +00:00
* Got rid of some additional internal sigc++ calls.
* Changed print_hhmmss/ddmmyyyy to use a char buffer. * Added error messages for failed torrent http/file downloads which includes the url/filename. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@581 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+20
-18
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <torrent/rate.h>
|
||||
@@ -48,6 +49,16 @@
|
||||
|
||||
namespace display {
|
||||
|
||||
char*
|
||||
print_string(char* buf, unsigned int length, char* str) {
|
||||
// We don't have any nice simple functions for copying strings that
|
||||
// return the end address.
|
||||
while (length-- != 0 && *str != '\0')
|
||||
*(buf++) = *(str++);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
char*
|
||||
print_download_title(char* buf, unsigned int length, core::Download* d) {
|
||||
return buf + std::max(0, snprintf(buf, length, "%s",
|
||||
@@ -102,37 +113,28 @@ print_download_status(char* buf, unsigned int length, core::Download* d) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
std::string
|
||||
print_hhmmss(utils::Timer t) {
|
||||
time_t tv_sec = static_cast<time_t>(t.tval().tv_sec);
|
||||
std::tm *u = std::localtime(&tv_sec);
|
||||
char*
|
||||
print_hhmmss(char* buf, unsigned int length, time_t t) {
|
||||
std::tm *u = std::localtime(&t);
|
||||
|
||||
if (u == NULL)
|
||||
return "inv_time";
|
||||
|
||||
std::stringstream str;
|
||||
str.fill('0');
|
||||
|
||||
str << std::setw(2) << u->tm_hour << ':' << std::setw(2) << u->tm_min << ':' << std::setw(2) << u->tm_sec;
|
||||
unsigned int s = snprintf(buf, length, "%02u:%02u:%02u", u->tm_hour, u->tm_min, u->tm_sec);
|
||||
|
||||
return str.str();
|
||||
return buf + std::min(s, length);
|
||||
}
|
||||
|
||||
std::string
|
||||
print_ddmmyyyy(time_t t) {
|
||||
char*
|
||||
print_ddmmyyyy(char* buf, unsigned int length, time_t t) {
|
||||
std::tm *u = std::gmtime(&t);
|
||||
|
||||
if (u == NULL)
|
||||
return "inv_time";
|
||||
|
||||
std::stringstream str;
|
||||
str.fill('0');
|
||||
|
||||
str << std::setw(2) << u->tm_mday << '/'
|
||||
<< std::setw(2) << (u->tm_mon + 1) << '/'
|
||||
<< std::setw(4) << (1900 + u->tm_year);
|
||||
unsigned int s = snprintf(buf, length, "%02u/%02u/%04u", u->tm_mday, (u->tm_mon + 1), (1900 + u->tm_year));
|
||||
|
||||
return str.str();
|
||||
return buf + std::min(s, length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user