#include "../shared/TclUtil.h" #include "../generate_alerts/data_framework/GenericTosData.h" #include "TclDataDebug.h" // This TCL command is (almost) exactly the same as sending the debug_tos // command directly to the server over the network. Presumably this is easier, // assuming you've got a TCL interpreter, and you're using the TCL shell client // program. static int debugTosCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "options"); return TCL_ERROR; } Debugger *debugger = GenericTosDataNode::getDebugger(); if (!debugger) { // This is possible. The main program has to tell GenericTosDataNode to // register it's debugger. This is probably a mistake if the debugger is // not registered. It costs almost nothing unless you use it, so most // programs would initialize it. This could happen if a program tries // to use the debugger before it's installed. Tcl_SetObjResult(interp, makeTclString("no debugger installed")); return TCL_ERROR; } Tcl_DictSearch search; int done; Tcl_Obj *key; Tcl_Obj *value; int result = Tcl_DictObjFirst(interp, objv[1], &search, &key, &value, &done); if (result != TCL_OK) // Not a valid dictionary. return TCL_ERROR; PropertyList options; while (!done) { options[getString(key)] = getString(value); Tcl_DictObjNext(&search, &key, &value, &done); } Tcl_DictObjDone(&search); // See GenericTosDataNode::onBroadcast() in // ../generate_alerts/data_framework/GenericTosData.C for details about // the options. debugger->sendRequest(options); return TCL_OK; } void installDataDebug(Tcl_Interp *interp) { Tcl_CreateObjCommand(interp, "ti::debug_tos", debugTosCmd, NULL, NULL); }