00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "ShutdownCommand.h"
00019 #include "CompletionNotifier.h"
00020 #include "DTNServer.h"
00021 #include "bundling/BundleDaemon.h"
00022
00023 namespace dtn {
00024
00025 ShutdownCommand::ShutdownCommand(DTNServer* dtnserver, const char* cmd)
00026 : TclCommand(cmd), dtnserver_(dtnserver)
00027 {
00028 add_to_help(cmd, "shutdown the daemon");
00029 }
00030
00031 void
00032 ShutdownCommand::call_exit(void* clientData)
00033 {
00034 (void)clientData;
00035 oasys::TclCommandInterp::instance()->exit_event_loop();
00036 }
00037
00038 int
00039 ShutdownCommand::exec(int argc, const char** argv, Tcl_Interp* interp)
00040 {
00041 (void)interp;
00042
00043
00044 if (argc != 1) {
00045 wrong_num_args(argc, argv, 1, 1, 1);
00046 return TCL_ERROR;
00047 }
00048
00049
00050
00051
00052 Tcl_CreateTimerHandler(0, ShutdownCommand::call_exit,
00053 (void*)dtnserver_);
00054
00055 return TCL_OK;
00056 }
00057
00058
00059 }