Index: /trunk/FACT++/src/dimctrl.cc
===================================================================
--- /trunk/FACT++/src/dimctrl.cc	(revision 12963)
+++ /trunk/FACT++/src/dimctrl.cc	(revision 12964)
@@ -1,38 +1,9 @@
-#include "Dim.h"
-#include "Configuration.h"
 #include "RemoteControl.h"
+#include "Main.h"
 
 using namespace std;
 
-template <class T>
-void RunShell(Configuration &conf)
-{
-    // A normal kill will call its destructor! (Very nice feature ;) )
-    static T shell(conf.GetName().c_str(),
-                   conf.Has("console") ? conf.Get<int>("console")!=1 : conf.Get<bool>("null"));
+// ========================================================================
 
-    WindowLog &win  = shell.GetStreamIn();
-    WindowLog &wout = shell.GetStreamOut();
-
-    if (conf.Has("log"))
-        if (!wout.OpenLogFile(conf.Get<string>("log"), conf.Get<bool>("append-log")))
-            win << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;
-
-    const vector<string> v1 = conf.Vec<string>("cmd");
-    for (vector<string>::const_iterator it=v1.begin(); it!=v1.end(); it++)
-        shell.ProcessLine(*it);
-
-    const vector<string> v2 = conf.Vec<string>("exec");
-    for (vector<string>::const_iterator it=v2.begin(); it!=v2.end(); it++)
-        shell.Execute(*it);
-
-    if (conf.Get<bool>("quit"))
-        shell.Stop();
-
-    shell.Run();
-}
-
-
-// ========================================================================
 
 /*
@@ -52,16 +23,28 @@
         "\n"
         "Usage: dimctrl [-c type] [OPTIONS]\n"
-        "  or:  dimctrl [OPTIONS]\n";
+        "  or:  dimctrl [OPTIONS]\n\n";
+
+    Main::PrintUsage();
     cout << endl;
-
 }
 
 void PrintHelp()
 {
-    /* Additional help text which is printed after the configuration
-     options goes here */
 }
 
-#include "Main.h"
+// A simple dummy state machine
+class DimCtrl : public MainImp, public MessageImp
+{
+    bool fStop;
+
+public:
+    DimCtrl(ostream &out=cout) : MessageImp(out), fStop(false)
+    {
+    }
+
+    int EvalOptions(Configuration &conf) { return -1; }
+    void Stop() { fStop = true; }
+    int Run(bool) { while (!fStop) usleep(1000); return 0; }
+};
 
 int main(int argc, const char *argv[])
@@ -74,13 +57,8 @@
         return -1;
 
-    Dim::Setup(conf.Get<string>("dns"), conf.Get<string>("host"));
-
     if (!conf.Has("console"))
-        //Main<RemoteShell, DummyService>(conf);
-        RunShell<RemoteShell>(conf);
+        return Main::execute<RemoteConsole, DimCtrl>(conf);
     else
-        //Main<RemoteConsole, DummyService>(conf);
-        RunShell<RemoteConsole>(conf);
-
+        return Main::execute<RemoteShell, DimCtrl>(conf);
 
     return 0;
