From fa6517317185b82b40f018e6d0f6a4668700fa1c Mon Sep 17 00:00:00 2001 From: drbob Date: Wed, 8 Aug 2012 09:23:26 +0000 Subject: [PATCH] switched output from std::cerr to std::cout.... now you can run ./retroshare-nogui 2> /dev/null to get a usable terminal rs console. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5391 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-nogui/src/menu/menu.cc | 224 ++++++++++++++--------------- retroshare-nogui/src/menu/menus.cc | 50 +++---- 2 files changed, 137 insertions(+), 137 deletions(-) diff --git a/retroshare-nogui/src/menu/menu.cc b/retroshare-nogui/src/menu/menu.cc index 604f127be..567dc4b29 100644 --- a/retroshare-nogui/src/menu/menu.cc +++ b/retroshare-nogui/src/menu/menu.cc @@ -51,8 +51,8 @@ uint32_t MenuInterface::process(char key) { #ifdef MENU_DEBUG - std::cerr << "MenuInterface::process(" << key << ")"; - std::cerr << std::endl; + std::cout << "MenuInterface::process(" << key << ")"; + std::cout << std::endl; #endif // MENU_DEBUG /* call process on current menu */ @@ -62,8 +62,8 @@ uint32_t MenuInterface::process(char key) bool showHelp = false; #ifdef MENU_DEBUG - std::cerr << "MenuInterface::process() currentMenu says: " << rt; - std::cerr << std::endl; + std::cout << "MenuInterface::process() currentMenu says: " << rt; + std::cout << std::endl; #endif // MENU_DEBUG switch(rt) @@ -92,15 +92,15 @@ uint32_t MenuInterface::process(char key) /* new menu to switch to */ if (mCurrentMenu->selectedMenu()) { - std::cerr << "MenuInterface::process() Switching Menus"; - std::cerr << std::endl; + std::cout << "MenuInterface::process() Switching Menus"; + std::cout << std::endl; mCurrentMenu = mCurrentMenu->selectedMenu(); } else { - std::cerr << "MenuInterface::process() ERROR"; - std::cerr << " SelectedMenu == NULL"; - std::cerr << std::endl; + std::cout << "MenuInterface::process() ERROR"; + std::cout << " SelectedMenu == NULL"; + std::cout << std::endl; } break; @@ -123,7 +123,7 @@ uint32_t MenuInterface::process(char key) /* HEADER */ for(int i = 0; i < 20; i++) { - std::cerr << std::endl; + std::cout << std::endl; } /* ERROR */ @@ -145,10 +145,10 @@ uint32_t MenuInterface::process(char key) uint32_t MenuInterface::drawHeader() { - std::cerr << "======================================================="; - std::cerr << std::endl; - std::cerr << "Retroshare Terminal Menu V2.xxxx ======================"; - std::cerr << std::endl; + std::cout << "======================================================="; + std::cout << std::endl; + std::cout << "Retroshare Terminal Menu V2.xxxx ======================"; + std::cout << std::endl; unsigned int nTotal = 0; unsigned int nConnected = 0; @@ -200,18 +200,18 @@ uint32_t MenuInterface::drawHeader() float upKb = 0; rsicontrol -> ConfigGetDataRates(downKb, upKb); - std::cerr << "Friends " << nConnected << "/" << nTotal; - std::cerr << " Network: " << natState; - std::cerr << std::endl; - std::cerr << "Down: " << downKb << " (kB/s) "; - std::cerr << " Up: " << upKb << " (kB/s) "; - std::cerr << std::endl; - std::cerr << "Menu State: "; - tailrec_printparents(mCurrentMenu, std::cerr); - std::cerr << std::endl; + std::cout << "Friends " << nConnected << "/" << nTotal; + std::cout << " Network: " << natState; + std::cout << std::endl; + std::cout << "Down: " << downKb << " (kB/s) "; + std::cout << " Up: " << upKb << " (kB/s) "; + std::cout << std::endl; + std::cout << "Menu State: "; + tailrec_printparents(mCurrentMenu, std::cout); + std::cout << std::endl; - std::cerr << "======================================================="; - std::cerr << std::endl; + std::cout << "======================================================="; + std::cout << std::endl; return 1; } @@ -241,8 +241,8 @@ int Menu::addMenuItem(char key, Menu *child) it = mChildren.find(key); if (it != mChildren.end()) { - std::cerr << "Menu::addMenuItem() ERROR DUPLICATE MENU ITEM"; - std::cerr << std::endl; + std::cout << "Menu::addMenuItem() ERROR DUPLICATE MENU ITEM"; + std::cout << std::endl; return 0; } mChildren[key] = child; @@ -337,23 +337,23 @@ uint32_t Menu::process_children(char key) uint32_t Menu::drawPage() { - std::cerr << "Universal Commands ( "; - std::cerr << (char) MENU_KEY_QUIT << ":Quit "; - std::cerr << (char) MENU_KEY_HELP << ":Help "; - std::cerr << (char) MENU_KEY_TOP << ":Top "; - std::cerr << (char) MENU_KEY_UP << ":Up "; - std::cerr << ")"; - std::cerr << std::endl; + std::cout << "Universal Commands ( "; + std::cout << (char) MENU_KEY_QUIT << ":Quit "; + std::cout << (char) MENU_KEY_HELP << ":Help "; + std::cout << (char) MENU_KEY_TOP << ":Top "; + std::cout << (char) MENU_KEY_UP << ":Up "; + std::cout << ")"; + std::cout << std::endl; - std::cerr << "Specific Commands ("; + std::cout << "Specific Commands ("; std::map::iterator it; for(it = mChildren.begin(); it != mChildren.end(); it++) { - std::cerr << (char) it->first << ":"; - std::cerr << it->second->ShortFnDesc() << " "; + std::cout << (char) it->first << ":"; + std::cout << it->second->ShortFnDesc() << " "; } - std::cerr << ")"; - std::cerr << std::endl; + std::cout << ")"; + std::cout << std::endl; return 1; } @@ -361,25 +361,25 @@ uint32_t Menu::drawPage() uint32_t Menu::drawHelpPage() { - std::cerr << "Menu Help: Universal Commands are:"; - std::cerr << std::endl; - std::cerr << "\tKey: " << (char) MENU_KEY_QUIT << " => Quit"; - std::cerr << std::endl; - std::cerr << "\tKey: " << (char) MENU_KEY_HELP << " => Help"; - std::cerr << std::endl; - std::cerr << "\tKey: " << (char) MENU_KEY_TOP << " => Top Menu"; - std::cerr << std::endl; - std::cerr << "\tKey: " << (char) MENU_KEY_UP << " => Up a Menu"; - std::cerr << std::endl; + std::cout << "Menu Help: Universal Commands are:"; + std::cout << std::endl; + std::cout << "\tKey: " << (char) MENU_KEY_QUIT << " => Quit"; + std::cout << std::endl; + std::cout << "\tKey: " << (char) MENU_KEY_HELP << " => Help"; + std::cout << std::endl; + std::cout << "\tKey: " << (char) MENU_KEY_TOP << " => Top Menu"; + std::cout << std::endl; + std::cout << "\tKey: " << (char) MENU_KEY_UP << " => Up a Menu"; + std::cout << std::endl; - std::cerr << "Specific Commands are:"; - std::cerr << std::endl; + std::cout << "Specific Commands are:"; + std::cout << std::endl; std::map::iterator it; for(it = mChildren.begin(); it != mChildren.end(); it++) { - std::cerr << "\tKey: " << (char) it->first << " => "; - std::cerr << it->second->ShortFnDesc(); - std::cerr << std::endl; + std::cout << "\tKey: " << (char) it->first << " => "; + std::cout << it->second->ShortFnDesc(); + std::cout << std::endl; } return 1; @@ -395,18 +395,18 @@ uint32_t MenuList::drawPage() { Menu::drawPage(); - std::cerr << "Navigation Commands ("; - //std::cerr << (char) MENULIST_KEY_LIST << ":List "; - std::cerr << (char) MENULIST_KEY_NEXT << ":Next "; - std::cerr << (char) MENULIST_KEY_PREV << ":Prev "; - std::cerr << ")"; - std::cerr << std::endl; + std::cout << "Navigation Commands ("; + //std::cout << (char) MENULIST_KEY_LIST << ":List "; + std::cout << (char) MENULIST_KEY_NEXT << ":Next "; + std::cout << (char) MENULIST_KEY_PREV << ":Prev "; + std::cout << ")"; + std::cout << std::endl; - std::cerr << "MenuList::Internals "; - std::cerr << "ListSize: " << getListCount(); - std::cerr << " SelectIdx: " << mSelectIdx; - std::cerr << " Cursor: " << mCursor; - std::cerr << std::endl; + std::cout << "MenuList::Internals "; + std::cout << "ListSize: " << getListCount(); + std::cout << " SelectIdx: " << mSelectIdx; + std::cout << " Cursor: " << mCursor; + std::cout << std::endl; int i = 0; @@ -420,28 +420,28 @@ uint32_t MenuList::drawPage() if (mSelectIdx >= 0) { - std::cerr << "Current Selection Idx: " << mSelectIdx << " : "; + std::cout << "Current Selection Idx: " << mSelectIdx << " : "; std::string desc; if (getEntryDesc(mSelectIdx, desc) & (desc != "")) { - std::cerr << desc; + std::cout << desc; } else { - std::cerr << "Missing Description"; + std::cout << "Missing Description"; } - std::cerr << std::endl; + std::cout << std::endl; } else { - std::cerr << "No Current Selection: Use 0 - 9 to choose an Entry"; - std::cerr << std::endl; + std::cout << "No Current Selection: Use 0 - 9 to choose an Entry"; + std::cout << std::endl; } - std::cerr << "Showing " << startCount; - std::cerr << " to " << endCount << " of " << listCount << " Entries"; - std::cerr << std::endl; + std::cout << "Showing " << startCount; + std::cout << " to " << endCount << " of " << listCount << " Entries"; + std::cout << std::endl; std::list::iterator it; for (it = mList.begin(); it != mList.end(); it++, i++) @@ -451,23 +451,23 @@ uint32_t MenuList::drawPage() { if (i == mSelectIdx) { - std::cerr << "SELECTED => (" << curIdx << ") "; + std::cout << "SELECTED => (" << curIdx << ") "; } else { - std::cerr << "\t(" << curIdx << ") "; + std::cout << "\t(" << curIdx << ") "; } std::string desc; if (getEntryDesc(i, desc) & (desc != "")) { - std::cerr << desc; + std::cout << desc; } else { - std::cerr << *it << " => "; - std::cerr << "Missing Description"; + std::cout << *it << " => "; + std::cout << "Missing Description"; } - std::cerr << std::endl; + std::cout << std::endl; } } @@ -478,23 +478,23 @@ uint32_t MenuList::drawHelpPage() { Menu::drawPage(); - std::cerr << "MenuList Help: Navigation Commands are:"; - std::cerr << std::endl; - //std::cerr << "\tKey: " << (char) MENULIST_KEY_LIST << " => List"; - //std::cerr << std::endl; - std::cerr << "\tKey: " << (char) MENULIST_KEY_NEXT << " => Next Page"; - std::cerr << std::endl; - std::cerr << "\tKey: " << (char) MENULIST_KEY_PREV << " => Prev Page"; - std::cerr << std::endl; + std::cout << "MenuList Help: Navigation Commands are:"; + std::cout << std::endl; + //std::cout << "\tKey: " << (char) MENULIST_KEY_LIST << " => List"; + //std::cout << std::endl; + std::cout << "\tKey: " << (char) MENULIST_KEY_NEXT << " => Next Page"; + std::cout << std::endl; + std::cout << "\tKey: " << (char) MENULIST_KEY_PREV << " => Prev Page"; + std::cout << std::endl; - std::cerr << "MenuList::drawPage() Internal Details"; - std::cerr << std::endl; - std::cerr << "List Size: " << getListCount(); - std::cerr << std::endl; - std::cerr << "SelectIdx: " << mSelectIdx; - std::cerr << std::endl; - std::cerr << "Cursor: " << mCursor; - std::cerr << std::endl; + std::cout << "MenuList::drawPage() Internal Details"; + std::cout << std::endl; + std::cout << "List Size: " << getListCount(); + std::cout << std::endl; + std::cout << "SelectIdx: " << mSelectIdx; + std::cout << std::endl; + std::cout << "Cursor: " << mCursor; + std::cout << std::endl; return 1; } @@ -584,13 +584,13 @@ uint32_t MenuList::list_process(char key) if (mCursor + idx < getListCount()) { mSelectIdx = mCursor + idx; - std::cerr << "MenuList::list_process() Selected Idx: " << mSelectIdx; - std::cerr << std::endl; + std::cout << "MenuList::list_process() Selected Idx: " << mSelectIdx; + std::cout << std::endl; } else { - std::cerr << "MenuList::list_process() Idx Out of Range"; - std::cerr << std::endl; + std::cout << "MenuList::list_process() Idx Out of Range"; + std::cout << std::endl; } return MENU_PROCESS_DONE; /* ready for next key stroke */ @@ -717,14 +717,14 @@ uint32_t MenuOpLineInput::op() uint32_t MenuOpLineInput::process_lines(std::string input) { - std::cerr << "MenuOpLineInput::process_lines() => SHOULD BE OVERLOADED"; - std::cerr << "Input Was: "; - std::cerr << std::endl; - std::cerr << "=================================================="; - std::cerr << std::endl; - std::cerr << input; - std::cerr << "=================================================="; - std::cerr << std::endl; + std::cout << "MenuOpLineInput::process_lines() => SHOULD BE OVERLOADED"; + std::cout << "Input Was: "; + std::cout << std::endl; + std::cout << "=================================================="; + std::cout << std::endl; + std::cout << input; + std::cout << "=================================================="; + std::cout << std::endl; return MENU_PROCESS_ERROR; } @@ -746,12 +746,12 @@ uint32_t MenuOpLineInput::process(char key) case MENU_PROCESS_NEEDDATA: break; case MENU_PROCESS_ERROR: - std::cerr << "MenuOpLineInput::process() => ERROR"; - std::cerr << std::endl; + std::cout << "MenuOpLineInput::process() => ERROR"; + std::cout << std::endl; case MENU_PROCESS_DONE: /* cleanup for next command */ - std::cerr << "MenuOpLineInput::process() Clearing Buffer"; - std::cerr << std::endl; + std::cout << "MenuOpLineInput::process() Clearing Buffer"; + std::cout << std::endl; mInput.clear(); /* go back to parent menu */ diff --git a/retroshare-nogui/src/menu/menus.cc b/retroshare-nogui/src/menu/menus.cc index c15d2eb3b..d81f24e95 100644 --- a/retroshare-nogui/src/menu/menus.cc +++ b/retroshare-nogui/src/menu/menus.cc @@ -186,16 +186,16 @@ int MenuListTransfer::getEntryDesc(int idx, std::string &desc) std::string hash; if (!getListEntry(idx, hash)) { - std::cerr << "MenuListTransfer::getEntryDesc() No ListEntry"; - std::cerr << std::endl; + std::cout << "MenuListTransfer::getEntryDesc() No ListEntry"; + std::cout << std::endl; return 0; } FileInfo info; if (!rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, info)) { - std::cerr << "MenuListTransfer::getEntryDesc() No FileDetails"; - std::cerr << std::endl; + std::cout << "MenuListTransfer::getEntryDesc() No FileDetails"; + std::cout << std::endl; return 0; } @@ -302,9 +302,9 @@ int MenuListSearch::getCurrentSearchId(uint32_t &id) int MenuListSearch::storeSearch(uint32_t searchId, std::string match_string) { - std::cerr << "MenuListSearch::storeSearch(" << searchId << " => "; - std::cerr << match_string; - std::cerr << std::endl; + std::cout << "MenuListSearch::storeSearch(" << searchId << " => "; + std::cout << match_string; + std::cout << std::endl; std::string strSearchId; rs_sprintf(strSearchId, "%lu", searchId); @@ -318,8 +318,8 @@ int MenuListSearch::storeSearch(uint32_t searchId, std::string match_string) int MenuListSearch::removeSearch(std::string strSearchId) { - std::cerr << "MenuListSearch::removeSearch(" << strSearchId << ")"; - std::cerr << std::endl; + std::cout << "MenuListSearch::removeSearch(" << strSearchId << ")"; + std::cout << std::endl; std::map::iterator it; it = mSearchIds.find(strSearchId); @@ -341,8 +341,8 @@ uint32_t MenuOpSearchNew::process_lines(std::string input) /* launch search */ if (input.size() < 4) { - std::cerr << "MenuOpSearchNew::process_lines() ERROR Input too small"; - std::cerr << std::endl; + std::cout << "MenuOpSearchNew::process_lines() ERROR Input too small"; + std::cout << std::endl; return MENU_PROCESS_ERROR; } @@ -378,8 +378,8 @@ uint32_t MenuListSearchList::refresh() MenuListSearch *mls = dynamic_cast(p); if (!mls) { - std::cerr << "MenuListSearchList::refresh() mls not there"; - std::cerr << std::endl; + std::cout << "MenuListSearchList::refresh() mls not there"; + std::cout << std::endl; return MENU_OP_ERROR; } @@ -389,13 +389,13 @@ uint32_t MenuListSearchList::refresh() uint32_t searchId; if (!mls->getCurrentSearchId(searchId)) { - std::cerr << "MenuListSearchList::refresh() currentIdx invalid"; - std::cerr << std::endl; + std::cout << "MenuListSearchList::refresh() currentIdx invalid"; + std::cout << std::endl; return MENU_OP_ERROR; } - std::cerr << "MenuListSearchList::refresh() searchId: " << searchId; - std::cerr << std::endl; + std::cout << "MenuListSearchList::refresh() searchId: " << searchId; + std::cout << std::endl; std::list::iterator it; mNotify->getSearchResults(searchId, mSearchResults); @@ -432,8 +432,8 @@ int MenuListSearchList::downloadSelected() { if (mSelectIdx < 0) { - std::cerr << "MenuListSearchList::downloadSelected() Invalid Selection"; - std::cerr << std::endl; + std::cout << "MenuListSearchList::downloadSelected() Invalid Selection"; + std::cout << std::endl; return MENU_ENTRY_NONE; } @@ -448,13 +448,13 @@ int MenuListSearchList::downloadSelected() if (rsFiles -> FileRequest(it->name, it->hash, it->size, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) { - std::cerr << "MenuListSearchList::downloadSelected() Download Started"; - std::cerr << std::endl; + std::cout << "MenuListSearchList::downloadSelected() Download Started"; + std::cout << std::endl; } else { - std::cerr << "MenuListSearchList::downloadSelected() Error Starting Download"; - std::cerr << std::endl; + std::cout << "MenuListSearchList::downloadSelected() Error Starting Download"; + std::cout << std::endl; } return MENU_ENTRY_OKAY; } @@ -469,8 +469,8 @@ uint32_t MenuOpSearchListDownload::op_basic(std::string key) MenuListSearchList *mlsl = dynamic_cast(p); if (!mlsl) { - std::cerr << "MenuOpSearchListDownload::op_basic() ERROR"; - std::cerr << std::endl; + std::cout << "MenuOpSearchListDownload::op_basic() ERROR"; + std::cout << std::endl; return MENU_OP_ERROR; }