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