Index: /nanovis/branches/1.2/Command.cpp
===================================================================
--- /nanovis/branches/1.2/Command.cpp	(revision 5602)
+++ /nanovis/branches/1.2/Command.cpp	(revision 5603)
@@ -37,5 +37,7 @@
 #include <unistd.h>                     /* Needed for getpid, gethostname,
                                          * write, etc. */
-
+#if !defined(USE_NEW_EVENT_LOOP) && !defined(USE_THREADS)
+#include <fcntl.h>
+#endif
 #include <sstream>
 
@@ -2236,4 +2238,79 @@
 }
 
+#if !defined(USE_NEW_EVENT_LOOP) && !defined(USE_THREADS)
+int
+nv::processCommands(Tcl_Interp *interp, FILE *inFile, int fdOut)
+{
+    int ret = 0;
+    int status = TCL_OK;
+
+    Tcl_DString cmdbuffer;
+    Tcl_DStringInit(&cmdbuffer);
+
+    int flags = fcntl(0, F_GETFL, 0);
+    fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
+
+    //  Read and execute as many commands as we can from stdin...
+    bool isComplete = false;
+    while ((!feof(inFile)) && (status == TCL_OK)) {
+        //
+        //  Read the next command from the buffer.  First time through we
+        //  block here and wait if necessary until a command comes in.
+        //
+        //  BE CAREFUL: Read only one command, up to a newline.  The "volume
+        //  data follows" command needs to be able to read the data
+        //  immediately following the command, and we shouldn't consume it
+        //  here.
+        //
+        while (!feof(inFile)) {
+            int c = fgetc(inFile);
+            char ch;
+            if (c <= 0) {
+                if (errno == EWOULDBLOCK) {
+                    break;
+                }
+                return -1;
+            }
+            ch = (char)c;
+            Tcl_DStringAppend(&cmdbuffer, &ch, 1);
+            if (ch == '\n') {
+                isComplete = Tcl_CommandComplete(Tcl_DStringValue(&cmdbuffer));
+                if (isComplete) {
+                    break;
+                }
+            }
+        }
+        // no command? then we're done for now
+        if (Tcl_DStringLength(&cmdbuffer) == 0) {
+            break;
+        }
+        if (isComplete) {
+            // back to original flags during command evaluation...
+            fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
+            struct timeval start, finish;
+            gettimeofday(&start, NULL);
+            status = ExecuteCommand(interp, &cmdbuffer);
+            gettimeofday(&finish, NULL);
+            // non-blocking for next read -- we might not get anything
+            fcntl(0, F_SETFL, flags | O_NONBLOCK);
+            isComplete = false;
+            g_stats.cmdTime += (MSECS_ELAPSED(start, finish) / 1.0e+3);
+            g_stats.nCommands++;
+        }
+    }
+    fcntl(0, F_SETFL, flags);
+
+    if (status != TCL_OK) {
+        if (handleError(interp, status, fdOut) < 0) {
+            return -1;
+        }
+        TRACE("Leaving on ERROR");
+    }
+
+    return ret;
+}
+
+#endif
+
 /**
  * \brief Execute commands from client in Tcl interpreter
Index: /nanovis/branches/1.2/Command.h
===================================================================
--- /nanovis/branches/1.2/Command.h	(revision 5602)
+++ /nanovis/branches/1.2/Command.h	(revision 5603)
@@ -37,4 +37,9 @@
 extern bool SocketRead(char *bytes, size_t len);
 
+#if !defined(USE_NEW_EVENT_LOOP) && !defined(USE_THREADS)
+extern int processCommands(Tcl_Interp *interp,
+                           FILE *inBufPtr,
+                           int fdOut);
+#endif
 extern int processCommands(Tcl_Interp *interp,
                            ReadBuffer *inBufPtr,
Index: /nanovis/branches/1.2/nanovisServer.cpp
===================================================================
--- /nanovis/branches/1.2/nanovisServer.cpp	(revision 5602)
+++ /nanovis/branches/1.2/nanovisServer.cpp	(revision 5603)
@@ -382,100 +382,4 @@
 }
 
-#if !defined(USE_NEW_EVENT_LOOP) && !defined(USE_THREADS)
-
-static int
-executeCommand(Tcl_Interp *interp, Tcl_DString *dsPtr) 
-{
-    int result;
-#ifdef WANT_TRACE
-    char *str = Tcl_DStringValue(dsPtr);
-    std::string cmd(str);
-    cmd.erase(cmd.find_last_not_of(" \n\r\t")+1);
-    TRACE("command %lu: '%s'", g_stats.nCommands+1, cmd.c_str());
-#endif
-
-    result = Tcl_Eval(interp, Tcl_DStringValue(dsPtr));
-    Tcl_DStringSetLength(dsPtr, 0);
-
-    if (result != TCL_OK) {
-        TRACE("Error: %d", result);
-    }
-    return result;
-}
-
-static int
-processCommands(Tcl_Interp *interp, FILE *inFile, int fdOut)
-{
-    int ret = 0;
-    int status = TCL_OK;
-
-    Tcl_DString cmdbuffer;
-    Tcl_DStringInit(&cmdbuffer);
-
-    int flags = fcntl(0, F_GETFL, 0);
-    fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
-
-    //  Read and execute as many commands as we can from stdin...
-    bool isComplete = false;
-    while ((!feof(inFile)) && (status == TCL_OK)) {
-        //
-        //  Read the next command from the buffer.  First time through we
-        //  block here and wait if necessary until a command comes in.
-        //
-        //  BE CAREFUL: Read only one command, up to a newline.  The "volume
-        //  data follows" command needs to be able to read the data
-        //  immediately following the command, and we shouldn't consume it
-        //  here.
-        //
-        while (!feof(inFile)) {
-            int c = fgetc(inFile);
-            char ch;
-            if (c <= 0) {
-                if (errno == EWOULDBLOCK) {
-                    break;
-                }
-                return -1;
-            }
-            ch = (char)c;
-            Tcl_DStringAppend(&cmdbuffer, &ch, 1);
-            if (ch == '\n') {
-                isComplete = Tcl_CommandComplete(Tcl_DStringValue(&cmdbuffer));
-                if (isComplete) {
-                    break;
-                }
-            }
-        }
-        // no command? then we're done for now
-        if (Tcl_DStringLength(&cmdbuffer) == 0) {
-            break;
-        }
-        if (isComplete) {
-            // back to original flags during command evaluation...
-            fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
-            struct timeval start, finish;
-            gettimeofday(&start, NULL);
-            status = executeCommand(interp, &cmdbuffer);
-            gettimeofday(&finish, NULL);
-            // non-blocking for next read -- we might not get anything
-            fcntl(0, F_SETFL, flags | O_NONBLOCK);
-            isComplete = false;
-            g_stats.cmdTime += (MSECS_ELAPSED(start, finish) / 1.0e+3);
-            g_stats.nCommands++;
-            CHECK_FRAMEBUFFER_STATUS();
-        }
-    }
-    fcntl(0, F_SETFL, flags);
-
-    if (status != TCL_OK) {
-        if (handleError(interp, status, fdOut) < 0) {
-            return -1;
-        }
-        TRACE("Leaving on ERROR");
-    }
-
-    return ret;
-}
-#endif
-
 static void
 idle()
@@ -486,5 +390,5 @@
 
 #if defined(USE_NEW_EVENT_LOOP) || defined(USE_THREADS)
-    if (nv::processCommands(NanoVis::interp, g_inBufPtr, g_fdOut) < 0) {
+    if (processCommands(NanoVis::interp, g_inBufPtr, g_fdOut) < 0) {
         exitService(1);
     }
