Added help text and port range option.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@288 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-02-18 21:51:13 +00:00
parent e0f21cce78
commit aa405810db
3 changed files with 50 additions and 27 deletions
+5
View File
@@ -1,3 +1,8 @@
Options and flags:
-p <a-b> Open a port in the range a to b.
All:
Ctrl-Q - Quit
+44 -26
View File
@@ -27,6 +27,9 @@ int64_t Timer::m_cache;
bool start_shutdown = false;
bool is_shutting_down = false;
void do_panic(int signum);
void print_help();
bool
is_resized() {
static int x = 0;
@@ -66,32 +69,6 @@ do_shutdown(ui::Control* c) {
start_shutdown = false;
}
void
do_panic(int signum) {
display::Canvas::cleanup();
std::cout << "Signal " << (signum == SIGSEGV ? "SIGSEGV" : "SIGBUS") << " recived, dumping stack:" << std::endl;
#ifdef USE_EXECINFO
void* stackPtrs[20];
// Print the stack and exit.
int stackSize = backtrace(stackPtrs, 20);
char** stackStrings = backtrace_symbols(stackPtrs, stackSize);
for (int i = 0; i < stackSize; ++i)
std::cout << i << ' ' << stackStrings[i] << std::endl;
#else
std::cout << "Stack dump not enabled." << std::endl;
#endif
if (signum == SIGBUS)
std::cout << "A bus error might mean you ran out of diskspace." << std::endl;
exit(-1);
}
int
main(int argc, char** argv) {
ui::Control uiControl;
@@ -103,6 +80,7 @@ main(int argc, char** argv) {
SignalHandler::set_handler(SIGBUS, sigc::bind(sigc::ptr_fun(&do_panic), SIGBUS));
OptionParser optionParser;
optionParser.insert_flag('h', sigc::ptr_fun(&print_help));
optionParser.insert_option('p', sigc::bind(sigc::ptr_fun(OptionParser::call_int_pair),
sigc::mem_fun(uiControl.get_core(), &core::Manager::set_port_range)));
@@ -149,9 +127,49 @@ main(int argc, char** argv) {
display::Canvas::cleanup();
std::cout << "Caught exception: \"" << e.what() << '"' << std::endl;
return -1;
}
uiControl.get_core().cleanup();
return 0;
}
void
do_panic(int signum) {
display::Canvas::cleanup();
std::cout << "Signal " << (signum == SIGSEGV ? "SIGSEGV" : "SIGBUS") << " recived, dumping stack:" << std::endl;
#ifdef USE_EXECINFO
void* stackPtrs[20];
// Print the stack and exit.
int stackSize = backtrace(stackPtrs, 20);
char** stackStrings = backtrace_symbols(stackPtrs, stackSize);
for (int i = 0; i < stackSize; ++i)
std::cout << i << ' ' << stackStrings[i] << std::endl;
#else
std::cout << "Stack dump not enabled." << std::endl;
#endif
if (signum == SIGBUS)
std::cout << "A bus error might mean you ran out of diskspace." << std::endl;
exit(-1);
}
void
print_help() {
std::cout << "Rakshasa's Torrent client. Neko-Mimi Mode-o!" << std::endl;
std::cout << "Usage: rtorrent [OPTIONS]... [FILE]... [URL]..." << std::endl;
std::cout << std::endl;
std::cout << " -h Display this very helpfull text" << std::endl;
std::cout << " -p <int>-<int> Set port range for incoming connections" << std::endl;
std::cout << std::endl;
std::cout << "Report bugs to <jaris@ifi.uio.no>." << std::endl;
exit(0);
}
+1 -1
View File
@@ -30,7 +30,7 @@ OptionParser::process(int argc, char** argv) {
while ((c = getopt(argc, argv, optString.c_str())) != -1) {
if (c == '?') {
std::stringstream s;
s << "Invalid use of option flag -" << (char)optopt;
s << "Invalid use of option flag -" << (char)optopt << ". Try rtorrent -h for more information.";
throw std::runtime_error(s.str());