int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { Publisher publisher (argc, argv); publisher.run (); } catch (Publisher::InitError& ex) { std::string& msg = reinterpret_cast<std::string&>(ex); std::cerr << "Initialization Error: " << msg.c_str() << std::endl; return -1; } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "ERROR: Publisher caught exception"); return -1; } return 0; }
static int main(int argc, char* argv[]) { Publisher generator; bool isAuto = false; bool isRead = false; int opt; while ((opt = getopt(argc, argv, "d:f:s:t:")) != -1) { switch (opt) { case 'd': { generator.dataPrefix = ndn::Name(std::string(optarg)); generator.mode = AUTO; isAuto = true; } break; case 'f': { isRead = true; generator.mode = READFILE; std::string str = std::string(optarg); generator.insertStream.open(str.c_str()); if (!generator.insertStream.is_open()) { std::cerr << "ERROR: cannot open " << std::string(optarg) << std::endl; return 1; } } break; case 's': try { generator.duration = milliseconds(boost::lexical_cast<uint64_t>(optarg)); } catch (const boost::bad_lexical_cast&) { std::cerr << "-s option should be an integer" << std::endl;; return 1; } break; case 't': try { generator.timeInterval = milliseconds(boost::lexical_cast<uint64_t>(optarg)); } catch (const boost::bad_lexical_cast&) { std::cerr << "-t option should be an integer" << std::endl;; return 1; } break; default: usage(); break; } } argc -= optind; argv += optind; if (argc != 0) usage(); if (isAuto && isRead) usage(); generator.run(); return 0; }