Index: /pymolproxy/trunk/pymolproxy.c
===================================================================
--- /pymolproxy/trunk/pymolproxy.c	(revision 5962)
+++ /pymolproxy/trunk/pymolproxy.c	(revision 5963)
@@ -1,14 +1,14 @@
-
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
  * ----------------------------------------------------------------------
- * proxypymol2.c
+ * proxypymol.c
  *
- *      This module creates the Tcl interface to the pymol server.  It acts as
- *      a go-between establishing communication between a molvisviewer widget
- *      and the pymol server. The communication protocol from the molvisviewer
- *      widget is the Tcl language.  Commands are then relayed to the pymol
- *      server.  Responses from the pymol server are translated into Tcl
- *      commands and send to the molvisviewer widget. For example, resulting
- *      image rendered offscreen is returned as ppm-formatted image data.
+ * This module creates the Tcl interface to the pymol server.  It acts as
+ * a go-between establishing communication between a molvisviewer widget
+ * and the pymol server. The communication protocol from the molvisviewer
+ * widget is the Tcl language.  Commands are then relayed to the pymol
+ * server.  Responses from the pymol server are translated into Tcl
+ * commands and send to the molvisviewer widget. For example, resulting
+ * image rendered offscreen is returned as ppm-formatted image data.
  *
  *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
@@ -20,22 +20,24 @@
 
 /*
- * Notes:   The proxy should not maintain any state information from the
- *	    client, other that what it needs for event (rotate, pan, zoom,
- *	    atom scale, bond thickness, etc.) compression.  This is because 
- *	    the connection is periodically broken (timeout, error, etc.).
- *	    It's the responsibility of the client (molvisviewer) to restore 
- *	    the settings of the previous view.  The proxy is just a relay
- *	    between the client and the pymol server.
+ * Notes:
+ *
+ * The proxy should not maintain any state information from the
+ * client, other that what it needs for event (rotate, pan, zoom,
+ * atom scale, bond thickness, etc.) compression.  This is because
+ * the connection is periodically broken (timeout, error, etc.).
+ * It's the responsibility of the client (molvisviewer) to restore
+ * the settings of the previous view.  The proxy is just a relay
+ * between the client and the pymol server.
  */
 /*
  *   +--------------+          +------------+          +----------+
- *   |              | (stdin)  |            |  (stdin) |          | 
+ *   |              | (stdin)  |            |  (stdin) |          |
  *   |              |--------->|            |--------->|          |
  *   | molvisviewer |          | pymolproxy |          | pymol    |
  *   |  (client)    |          |            |          | (server) |(stderr)
  *   |              | (stdout) |            | (stdout) |          |-------> file
- *   |              |<---------|            |<---------|          | 
+ *   |              |<---------|            |<---------|          |
  *   +--------------+          +------------+          +----------+
- * 
+ *
  * We're using a simple 2 thread setup: one for read client requests and
  * relaying them to the pymol server, another reading pymol server output,
@@ -46,12 +48,12 @@
  *
  * Reader thread:
- * The communication between the pymol server and proxy is asynchronous.  
+ * The communication between the pymol server and proxy is asynchronous.
  * The proxy translates commands from the client and sends them to the
  * server without waiting for a response.  It watches the server's
- * stdout in a separate thread snooping for image data.  
+ * stdout in a separate thread snooping for image data.
  *
  * Writer thread:
- * The communication between the client and the proxy is also asynchronous.  
- * The client commands are read when they become available on the socket.  
+ * The communication between the client and the proxy is also asynchronous.
+ * The client commands are read when they become available on the socket.
  * The proxy writes images to the client when it can, otherwise it stores
  * them in a list in memory.  This should prevent deadlocks from occuring:
@@ -98,8 +100,8 @@
 static int statsFile = -1;
 
-#define WANT_DEBUG	0
-#define READ_DEBUG	0
-#define WRITE_DEBUG	0
-#define EXEC_DEBUG	0
+#define WANT_DEBUG  0
+#define READ_DEBUG  0
+#define WRITE_DEBUG 0
+#define EXEC_DEBUG  0
 
 #define FORCE_UPDATE		(1<<0)
@@ -115,10 +117,10 @@
 
 #define IO_TIMEOUT (30000)
-#define CLIENT_READ		STDIN_FILENO
-#define CLIENT_WRITE		STDOUT_FILENO
+#define CLIENT_READ  STDIN_FILENO
+#define CLIENT_WRITE STDOUT_FILENO
 
 #ifndef LOGDIR
-#define LOGDIR		"/tmp"
-#endif	/* LOGDIR */
+#define LOGDIR "/tmp"
+#endif /* LOGDIR */
 
 #define CVT2SECS(x)  ((double)(x).tv_sec) + ((double)(x).tv_usec * 1.0e-6)
@@ -155,5 +157,5 @@
 } Image;
 
-#define BUFFER_SIZE		4096
+#define BUFFER_SIZE 4096
 
 typedef struct {
@@ -174,8 +176,8 @@
 } ReadBuffer;
 
-#define BUFFER_OK		 0
-#define BUFFER_ERROR		-1
-#define BUFFER_CONTINUE		-2
-#define BUFFER_EOF		-3
+#define BUFFER_OK        0
+#define BUFFER_ERROR    -1
+#define BUFFER_CONTINUE -2
+#define BUFFER_EOF      -3
 
 typedef struct {
@@ -203,23 +205,23 @@
 
 #if WANT_DEBUG
-#define DEBUG(...)	if (debug) PrintToLog(__VA_ARGS__)
-#else 
-#define DEBUG(...) 
-#endif
-
-#define ERROR(...)      SysLog(LOG_ERR, __FILE__, __LINE__, __VA_ARGS__)
-#define TRACE(...)      SysLog(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
-#define WARN(...)       SysLog(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__)
-#define INFO(...)       SysLog(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
+#define DEBUG(...) if (debug) PrintToLog(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
+
+#define ERROR(...) SysLog(LOG_ERR, __FILE__, __LINE__, __VA_ARGS__)
+#define TRACE(...) SysLog(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
+#define WARN(...)  SysLog(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__)
+#define INFO(...)  SysLog(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
 
 static const char *syslogLevels[] = {
-    "emergency",			/* System is unusable */
-    "alert",				/* Action must be taken immediately */
-    "critical",				/* Critical conditions */
-    "error",				/* Error conditions */
-    "warning",				/* Warning conditions */
-    "notice",				/* Normal but significant condition */
-    "info",				/* Informational */
-    "debug",				/* Debug-level messages */
+    "emergency", /* System is unusable */
+    "alert",     /* Action must be taken immediately */
+    "critical",  /* Critical conditions */
+    "error",     /* Error conditions */
+    "warning",   /* Warning conditions */
+    "notice",    /* Normal but significant condition */
+    "info",      /* Informational */
+    "debug",     /* Debug-level messages */
 };
 
@@ -230,5 +232,5 @@
     const char *format;
     va_list args;
-    
+
     format = TCL_VARARGS_START(const char *, arg1, args);
     fprintf(stderr, "pymolproxy: ");
@@ -255,12 +257,12 @@
         s++;
     }
-    length = snprintf(message, MSG_LEN, "pymolproxy (%d) %s: %s:%d ", 
-	getpid(), syslogLevels[priority],  s, lineNum);
+    length = snprintf(message, MSG_LEN, "pymolproxy (%d) %s: %s:%d ",
+        getpid(), syslogLevels[priority],  s, lineNum);
     length += vsnprintf(message + length, MSG_LEN - length, fmt, lst);
     message[MSG_LEN] = '\0';
     if (debug) {
-	DEBUG("%s\n", message);
+        DEBUG("%s\n", message);
     } else {
-	syslog(priority, message, length);
+        syslog(priority, message, length);
     }
 }
@@ -271,5 +273,5 @@
     const char *format;
     va_list args;
-    
+
     format = TCL_VARARGS_START(const char *, arg1, args);
     vfprintf(frecord, format, args);
@@ -289,22 +291,22 @@
         return TCL_ERROR;
     }
-    
+
     va_start(ap, format);
     result = vsnprintf(buffer, BUFSIZ-1, format, ap);
     va_end(ap);
-    
+
 #ifdef EXEC_DEBUG
     DEBUG("to-pymol>(%s) code=%d", buffer, result);
 #endif
     if (recording) {
-	Record("%s\n", buffer);
-    }
-    
+        Record("%s\n", buffer);
+    }
+
     /* Write the command out to the server. */
     length = strlen(buffer);
     numWritten = write(proxyPtr->sin, buffer, length);
     if (numWritten != length) {
-	ERROR("short write to pymol (wrote=%d, should have been %d): %s",
-	      numWritten, length, strerror(errno));
+        ERROR("short write to pymol (wrote=%d, should have been %d): %s",
+              numWritten, length, strerror(errno));
     }
     proxyPtr->status = result;
@@ -355,32 +357,32 @@
 
     if (bp->newline > 0) {
-	return bp->newline;
+        return bp->newline;
     } else {
-	unsigned char *p;
-	size_t newline;
-
-	p = (unsigned char *)memchr(bp->bytes + bp->mark, '\n', 
-				    bp->fill - bp->mark);
-	if (p == NULL) {
-	    newline = 0;
-	} else {
-	    newline = (p - bp->bytes + 1);
-	}
-	bp->newline = newline;
-	return newline;
-    }
-}
-
-/**  
+        unsigned char *p;
+        size_t newline;
+
+        p = (unsigned char *)memchr(bp->bytes + bp->mark, '\n',
+                                    bp->fill - bp->mark);
+        if (p == NULL) {
+            newline = 0;
+        } else {
+            newline = (p - bp->bytes + 1);
+        }
+        bp->newline = newline;
+        return newline;
+    }
+}
+
+/**
  * \brief Fills the buffer with available data.
- * 
- * Any existing data in the buffer is moved to the front of the buffer, 
+ *
+ * Any existing data in the buffer is moved to the front of the buffer,
  * then the channel is read to fill the rest of the buffer.
  *
  * \return If an error occur when reading the channel, then ERROR is
- * returned. ENDFILE is returned on EOF.  If the buffer can't be filled, 
+ * returned. ENDFILE is returned on EOF.  If the buffer can't be filled,
  * then CONTINUE is returned.
  */
-static int 
+static int
 FillReadBuffer(ReadBuffer *bp)
 {
@@ -389,9 +391,9 @@
 
 #if READ_DEBUG
-    DEBUG("Enter FillReadBuffer for %s: mark=%lu fill=%lu", 
-	  bp->ident, bp->mark, bp->fill);
+    DEBUG("Enter FillReadBuffer for %s: mark=%lu fill=%lu",
+          bp->ident, bp->mark, bp->fill);
 #endif
     if (bp->mark >= bp->fill) {
-        FlushReadBuffer(bp);	/* Fully consumed buffer */
+        FlushReadBuffer(bp); /* Fully consumed buffer */
     }
     if (bp->mark > 0) {
@@ -401,6 +403,6 @@
         DEBUG("memmove %lu bytes", bp->fill - bp->mark);
 #endif
-        memmove(bp->bytes, bp->bytes + bp->mark, 
-		bp->fill - bp->mark);
+        memmove(bp->bytes, bp->bytes + bp->mark,
+                bp->fill - bp->mark);
         bp->fill -= bp->mark;
         bp->mark = 0;
@@ -415,6 +417,6 @@
         /* EOF */
 #if READ_DEBUG
-        DEBUG("EOF found reading %s buffer (fill=%d): ", 
-	      bp->ident, bp->fill);
+        DEBUG("EOF found reading %s buffer (fill=%d): ",
+              bp->ident, bp->fill);
 #endif
         return BUFFER_EOF;
@@ -440,6 +442,6 @@
  * \brief Read the requested number of bytes from the buffer.
 
- * Fails if the requested number of bytes are not immediately 
- * available. Never should be short. 
+ * Fails if the requested number of bytes are not immediately
+ * available. Never should be short.
  */
 static int
@@ -469,6 +471,6 @@
         /* Didn't get enough bytes, need to read some more. */
         bp->lastStatus = FillReadBuffer(bp);
-        if ((bp->lastStatus == BUFFER_ERROR) || 
-	    (bp->lastStatus == BUFFER_EOF)) {
+        if ((bp->lastStatus == BUFFER_ERROR) ||
+            (bp->lastStatus == BUFFER_EOF)) {
             return bp->lastStatus;
         }
@@ -477,7 +479,7 @@
 }
 
-/** 
+/**
  * \brief Returns the next available line (terminated by a newline)
- * 
+ *
  * If insufficient data is in the buffer, then the channel is
  * read for more data.  If reading the channel results in a
@@ -504,5 +506,5 @@
             *numBytesPtr = newline - bp->mark;
             bp->mark = newline;
-	    bp->newline = 0;
+            bp->newline = 0;
             return BUFFER_OK;
         }
@@ -537,5 +539,5 @@
 
     if (IsLineAvailable(bp)) {
-	return 1;
+        return 1;
     }
     FD_ZERO(&readFds);
@@ -553,5 +555,5 @@
 
 #ifndef STATSDIR
-#define STATSDIR	"/var/tmp/visservers"
+#define STATSDIR "/var/tmp/visservers"
 #endif  /*STATSDIR*/
 
@@ -569,5 +571,5 @@
 
     if ((string == NULL) || (statsFile >= 0)) {
-	return statsFile;
+        return statsFile;
     }
     /* By itself the client's key/value pairs aren't unique.  Add in the
@@ -597,6 +599,6 @@
     Tcl_DStringFree(&ds);
     if (statsFile < 0) {
-	ERROR("can't open \"%s\": %s", fileName, strerror(errno));
-	return -1;
+        ERROR("can't open \"%s\": %s", fileName, strerror(errno));
+        return -1;
     }
     return statsFile;
@@ -608,5 +610,5 @@
 
     if (f >= 0) {
-	ssize_t numWritten;
+        ssize_t numWritten;
 
         numWritten = write(f, s, length);
@@ -619,5 +621,5 @@
 
 static int
-ServerStats(int code) 
+ServerStats(int code)
 {
     double start, finish;
@@ -628,13 +630,13 @@
 
     {
-	struct timeval tv;
-
-	/* Get ending time.  */
-	gettimeofday(&tv, NULL);
-	finish = CVT2SECS(tv);
-	tv = stats.start;
-	start = CVT2SECS(tv);
-    }
-    /* 
+        struct timeval tv;
+
+        /* Get ending time.  */
+        gettimeofday(&tv, NULL);
+        finish = CVT2SECS(tv);
+        tv = stats.start;
+        start = CVT2SECS(tv);
+    }
+    /*
      * Session information:
      *   - Name of render server
@@ -649,12 +651,12 @@
      *   - Total elapsed time of session
      *   - Exit code of vizserver
-     *   - User time 
+     *   - User time
      *   - System time
-     *   - User time of children 
-     *   - System time of children 
-     */ 
+     *   - User time of children
+     *   - System time of children
+     */
 
     Tcl_DStringInit(&ds);
-    
+
     Tcl_DStringAppendElement(&ds, "render_stop");
     /* renderer */
@@ -704,26 +706,26 @@
     Tcl_DStringAppendElement(&ds, buf);
     {
-	long clocksPerSec = sysconf(_SC_CLK_TCK);
-	double clockRes = 1.0 / clocksPerSec;
-	struct tms tms;
-
-	memset(&tms, 0, sizeof(tms));
-	times(&tms);
-	/* utime */
-	Tcl_DStringAppendElement(&ds, "utime");
-	sprintf(buf, "%g", tms.tms_utime * clockRes);
-	Tcl_DStringAppendElement(&ds, buf);
-	/* stime */
-	Tcl_DStringAppendElement(&ds, "stime");
-	sprintf(buf, "%g", tms.tms_stime * clockRes);
-	Tcl_DStringAppendElement(&ds, buf);
-	/* cutime */
-	Tcl_DStringAppendElement(&ds, "cutime");
-	sprintf(buf, "%g", tms.tms_cutime * clockRes);
-	Tcl_DStringAppendElement(&ds, buf);
-	/* cstime */
-	Tcl_DStringAppendElement(&ds, "cstime");
-	sprintf(buf, "%g", tms.tms_cstime * clockRes);
-	Tcl_DStringAppendElement(&ds, buf);
+        long clocksPerSec = sysconf(_SC_CLK_TCK);
+        double clockRes = 1.0 / clocksPerSec;
+        struct tms tms;
+
+        memset(&tms, 0, sizeof(tms));
+        times(&tms);
+        /* utime */
+        Tcl_DStringAppendElement(&ds, "utime");
+        sprintf(buf, "%g", tms.tms_utime * clockRes);
+        Tcl_DStringAppendElement(&ds, buf);
+        /* stime */
+        Tcl_DStringAppendElement(&ds, "stime");
+        sprintf(buf, "%g", tms.tms_stime * clockRes);
+        Tcl_DStringAppendElement(&ds, buf);
+        /* cutime */
+        Tcl_DStringAppendElement(&ds, "cutime");
+        sprintf(buf, "%g", tms.tms_cutime * clockRes);
+        Tcl_DStringAppendElement(&ds, buf);
+        /* cstime */
+        Tcl_DStringAppendElement(&ds, "cstime");
+        sprintf(buf, "%g", tms.tms_cstime * clockRes);
+        Tcl_DStringAppendElement(&ds, buf);
     }
     Tcl_DStringAppend(&ds, "\n", -1);
@@ -737,6 +739,6 @@
 
 static int
-CartoonCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	   const char *argv[])
+CartoonCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+           const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -751,27 +753,27 @@
         if (strcmp(argv[i],"-defer") == 0) {
             defer = TRUE;
-	} else if (strcmp(argv[i],"-push") == 0) {
+        } else if (strcmp(argv[i],"-push") == 0) {
             push = TRUE;
-	} else if (strcmp(argv[i],"-model") == 0) {
+        } else if (strcmp(argv[i],"-model") == 0) {
             if (++i < argc) {
                 model = argv[i];
-	    }
-	} else { 
-	    if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
-		return TCL_ERROR;
-	    }
-	}
-    }
-    p->flags |= INVALIDATE_CACHE;	/* cartoon */
+            }
+        } else {
+            if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
+                return TCL_ERROR;
+            }
+        }
+    }
+    p->flags |= INVALIDATE_CACHE; /* cartoon */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     if (bool) {
-	SendToPymol(p, "show cartoon,%s\n", model);
+        SendToPymol(p, "show cartoon,%s\n", model);
     } else {
-	SendToPymol(p, "hide cartoon,%s\n", model);
+        SendToPymol(p, "hide cartoon,%s\n", model);
     }
     return p->status;
@@ -779,6 +781,6 @@
 
 static int
-CartoonTraceCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-		const char *argv[])
+CartoonTraceCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+                const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -792,22 +794,22 @@
         if (strcmp(argv[i],"-defer") == 0) {
             defer = TRUE;
-	} else if (strcmp(argv[i],"-push") == 0) {
+        } else if (strcmp(argv[i],"-push") == 0) {
             push = TRUE;
-	} else if (strcmp(argv[i],"-model") == 0) {
+        } else if (strcmp(argv[i],"-model") == 0) {
             if (++i < argc) {
                 model = argv[i];
-	    }
-	} else { 
-	    if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
-		return TCL_ERROR;
-	    }
-	}
+            }
+        } else {
+            if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
+                return TCL_ERROR;
+            }
+        }
     }
     p->flags |= INVALIDATE_CACHE; /* cartoon_trace  */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     SendToPymol(p, "set cartoon_trace,%d,%s\n", bool, model);
@@ -816,6 +818,6 @@
 
 static int
-DisableCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	   const char *argv[])
+DisableCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+           const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -834,10 +836,10 @@
     }
 
-    p->flags |= INVALIDATE_CACHE;	/* disable */
+    p->flags |= INVALIDATE_CACHE; /* disable */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     SendToPymol(p, "disable %s\n", model);
@@ -847,6 +849,6 @@
 
 static int
-EnableCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	  const char *argv[])
+EnableCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+          const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -860,16 +862,16 @@
         if (strcmp(argv[i],"-defer") == 0) {
             defer = TRUE;
-	} else if (strcmp(argv[i], "-push") == 0) {
+        } else if (strcmp(argv[i], "-push") == 0) {
             push = TRUE;
-	} else {
+        } else {
             model = argv[i];
-	}
+        }
     }
     p->flags |= INVALIDATE_CACHE; /* enable */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     SendToPymol(p, "enable %s\n", model);
@@ -878,6 +880,6 @@
 
 static int
-FrameCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	 const char *argv[])
+FrameCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+         const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -887,18 +889,18 @@
     frame = 0;
     push = defer = FALSE;
-    for(i = 1; i < argc; i++) { 
+    for(i = 1; i < argc; i++) {
         if (strcmp(argv[i],"-defer") == 0) {
             defer = TRUE;
-	} else if (strcmp(argv[i],"-push") == 0) {
+        } else if (strcmp(argv[i],"-push") == 0) {
             push = TRUE;
-	} else {
+        } else {
             frame = atoi(argv[i]);
-	}
+        }
     }
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     p->frame = frame;
@@ -910,13 +912,12 @@
 }
 
-/* 
+/*
  * ClientInfoCmd --
  *
- *	  
- *	clientinfo path list
+ * clientinfo path list
  */
 static int
-ClientInfoCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	      const char *argv[])
+ClientInfoCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+              const char *argv[])
 {
     Tcl_DString ds;
@@ -929,7 +930,7 @@
 
     if (argc != 2) {
-	Tcl_AppendResult(interp, "wrong # of arguments: should be \"", argv[0],
-		" list\"", (char *)NULL);
-	return TCL_ERROR;
+        Tcl_AppendResult(interp, "wrong # of arguments: should be \"", argv[0],
+                " list\"", (char *)NULL);
+        return TCL_ERROR;
     }
     /* Use the initial client key value pairs as the parts for a generating
@@ -937,7 +938,7 @@
     f = GetStatsFile(argv[1]);
     if (f < 0) {
-	Tcl_AppendResult(interp, "can't open stats file: ", 
+        Tcl_AppendResult(interp, "can't open stats file: ",
                          Tcl_PosixError(interp), (char *)NULL);
-	return TCL_ERROR;
+        return TCL_ERROR;
     }
     Tcl_DStringInit(&ds);
@@ -947,14 +948,14 @@
         /* renderer */
         Tcl_DStringAppendElement(&ds, "renderer");
-	Tcl_DStringAppendElement(&ds, "pymol");
+        Tcl_DStringAppendElement(&ds, "pymol");
         /* pid */
-	Tcl_DStringAppendElement(&ds, "pid");
-	sprintf(buf, "%d", getpid());
-	Tcl_DStringAppendElement(&ds, buf);
+        Tcl_DStringAppendElement(&ds, "pid");
+        sprintf(buf, "%d", getpid());
+        Tcl_DStringAppendElement(&ds, buf);
         /* host */
         Tcl_DStringAppendElement(&ds, "host");
-	gethostname(buf, BUFSIZ-1);
-	buf[BUFSIZ-1] = '\0';
-	Tcl_DStringAppendElement(&ds, buf);
+        gethostname(buf, BUFSIZ-1);
+        buf[BUFSIZ-1] = '\0';
+        Tcl_DStringAppendElement(&ds, buf);
     } else {
         Tcl_DStringAppendElement(&ds, "render_info");
@@ -972,8 +973,8 @@
     /* Client arguments. */
     if (Tcl_SplitList(interp, argv[1], &numElems, &elems) != TCL_OK) {
-	return TCL_ERROR;
+        return TCL_ERROR;
     }
     for (i = 0; i < numElems; i++) {
-	Tcl_DStringAppendElement(&ds, elems[i]);
+        Tcl_DStringAppendElement(&ds, elems[i]);
     }
     free(elems);
@@ -985,6 +986,6 @@
 
 static int
-LabelCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	 const char *argv[])
+LabelCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+         const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1000,27 +1001,27 @@
         if (strcmp(argv[i],"-defer") == 0) {
             defer = TRUE;
-	} else if (strcmp(argv[i],"-push") == 0) {
+        } else if (strcmp(argv[i],"-push") == 0) {
             push = TRUE;
-	} else if (strcmp(argv[i],"-model") == 0) {
+        } else if (strcmp(argv[i],"-model") == 0) {
             if (++i < argc) {
                 model = argv[i];
-	    }
-	} else if (strcmp(argv[i],"-size") == 0) {
+            }
+        } else if (strcmp(argv[i],"-size") == 0) {
             if (++i < argc) {
                 size = atoi(argv[i]);
-	    }
-	} else if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
-	    return TCL_ERROR;
-	}
-    }
-    p->flags |= INVALIDATE_CACHE;	/* label */
+            }
+        } else if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
+            return TCL_ERROR;
+        }
+    }
+    p->flags |= INVALIDATE_CACHE; /* label */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
-    }
-    SendToPymol(p, "set label_color,white,%s\nset label_size,%d,%s\n", 
-	    model, size, model);
+        p->flags |= FORCE_UPDATE;
+    }
+    SendToPymol(p, "set label_color,white,%s\nset label_size,%d,%s\n",
+            model, size, model);
     if (bool) {
         SendToPymol(p, "label %s,\"%%s%%s\" %% (ID,name)\n", model);
@@ -1031,17 +1032,16 @@
 }
 
-/* 
+/*
  * LoadPDBCmd --
  *
- *	Load a PDB into pymol.  We write the pdb data into a temporary file
- *	and then let pymol read it and delete it.  There is no good way to
- *	load PDB data into pymol without using a file.  The specially created
- *	routine "loadandremovepdbfile" in pymol will remove the file after
- *	loading it.  
- *
+ * Load a PDB into pymol.  We write the pdb data into a temporary file
+ * and then let pymol read it and delete it.  There is no good way to
+ * load PDB data into pymol without using a file.  The specially created
+ * routine "loadandremovepdbfile" in pymol will remove the file after
+ * loading it.
  */
 static int
-LoadPDBCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	   const char *argv[])
+LoadPDBCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+           const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1055,57 +1055,57 @@
 
     if (p == NULL){
-	return TCL_ERROR;
+        return TCL_ERROR;
     }
     clear_error(p);
     defer = push = FALSE;
     for(i = j = 1; i < argc; i++) {
-	if (strcmp(argv[i],"-defer") == 0) {
-	    defer = TRUE;
-	} else if (strcmp(argv[i],"-push") == 0) {
-	    push = TRUE;
-	} else {
-	    if (j < i) {
-		argv[j] = argv[i];
-	    }
-	    j++;
-	}
+        if (strcmp(argv[i],"-defer") == 0) {
+            defer = TRUE;
+        } else if (strcmp(argv[i],"-push") == 0) {
+            push = TRUE;
+        } else {
+            if (j < i) {
+                argv[j] = argv[i];
+            }
+            j++;
+        }
     }
     argc = j;
     if (argc < 4) {
-	Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
-			 " <data>|follows <model> <state> ?<numBytes>?\"",
-			 (char *)NULL);
-	return TCL_ERROR;
+        Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
+                         " <data>|follows <model> <state> ?<numBytes>?\"",
+                         (char *)NULL);
+        return TCL_ERROR;
     }
     string = argv[1];
     name   = argv[2];
     if (Tcl_GetInt(interp, argv[3], &state) != TCL_OK) {
-	return TCL_ERROR;
+        return TCL_ERROR;
     }
     numBytes = 0;
     status = BUFFER_ERROR;
     if (strcmp(string, "follows") == 0) {
-	int n;
-
-	if (argc != 5) {
-	    Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
-			 " follows <model> <state> <numBytes>\"", (char *)NULL);
-	    return TCL_ERROR;
-	}
-	if (Tcl_GetInt(interp, argv[4], &n) != TCL_OK) {
-	    return TCL_ERROR;
-	}
-	if (n < 0) {
-	    Tcl_AppendResult(interp, "bad value for # bytes \"", argv[4],
-			 "\"", (char *)NULL);
-	    return TCL_ERROR;
-	}
-	numBytes = (size_t)n;
+        int n;
+
+        if (argc != 5) {
+            Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
+                         " follows <model> <state> <numBytes>\"", (char *)NULL);
+            return TCL_ERROR;
+        }
+        if (Tcl_GetInt(interp, argv[4], &n) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if (n < 0) {
+            Tcl_AppendResult(interp, "bad value for # bytes \"", argv[4],
+                         "\"", (char *)NULL);
+            return TCL_ERROR;
+        }
+        numBytes = (size_t)n;
     }
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     p->cacheId = state;
@@ -1116,44 +1116,44 @@
     allocated = malloc(sizeof(char) * numBytes);
     if (allocated == NULL) {
-	Tcl_AppendResult(interp, "can't allocate buffer for pdbdata.",
-			 (char *)NULL);
-	return TCL_ERROR;
+        Tcl_AppendResult(interp, "can't allocate buffer for pdbdata.",
+                         (char *)NULL);
+        return TCL_ERROR;
     }
     status = ReadFollowingData(&p->client, allocated, numBytes);
     if (status != BUFFER_OK) {
-	Tcl_AppendResult(interp, "can't read pdbdata from client.",
-			 (char *)NULL);
-	free(allocated);
-	return TCL_ERROR;
+        Tcl_AppendResult(interp, "can't read pdbdata from client.",
+                         (char *)NULL);
+        free(allocated);
+        return TCL_ERROR;
     }
     string = (const char *)allocated;
     {
-	int f;
-	ssize_t numWritten;
-	char fileName[200];
-
-	strcpy(fileName, "/tmp/pdb.XXXXXX");
-	p->status = TCL_ERROR;
-	f = mkstemp(fileName);
-	if (f < 0) {
-	    Tcl_AppendResult(interp, "can't create temporary file \"", 
-		fileName, "\":", Tcl_PosixError(interp), (char *)NULL);
-	    goto error;
-	} 
-	numWritten = write(f, string, numBytes);
-	if (numBytes != numWritten) {
-	    Tcl_AppendResult(interp, "can't write PDB data to \"",
-		fileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
-	    close(f);
-	    goto error;
-	}
-	close(f);
-	SendToPymol(p, "loadandremovepdbfile %s,%s,%d\n", fileName, name, 
-		    state);
-	p->status = TCL_OK;
+        int f;
+        ssize_t numWritten;
+        char fileName[200];
+
+        strcpy(fileName, "/tmp/pdb.XXXXXX");
+        p->status = TCL_ERROR;
+        f = mkstemp(fileName);
+        if (f < 0) {
+            Tcl_AppendResult(interp, "can't create temporary file \"",
+                fileName, "\":", Tcl_PosixError(interp), (char *)NULL);
+            goto error;
+        }
+        numWritten = write(f, string, numBytes);
+        if (numBytes != numWritten) {
+            Tcl_AppendResult(interp, "can't write PDB data to \"",
+                fileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
+            close(f);
+            goto error;
+        }
+        close(f);
+        SendToPymol(p, "loadandremovepdbfile %s,%s,%d\n", fileName, name,
+                    state);
+        p->status = TCL_OK;
     }
  error:
     if (allocated != NULL) {
-	free(allocated);
+        free(allocated);
     }
     return p->status;
@@ -1161,6 +1161,6 @@
 
 static int
-OrthoscopicCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	      const char *argv[])
+OrthoscopicCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+              const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1173,18 +1173,18 @@
         if (strcmp(argv[i],"-defer") == 0) {
             defer = TRUE;
-	} else if (strcmp(argv[i],"-push") == 0) {
+        } else if (strcmp(argv[i],"-push") == 0) {
             push = TRUE;
-	} else { 
-	    if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
-		return TCL_ERROR;
-	    }
-	}
+        } else {
+            if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
+                return TCL_ERROR;
+            }
+        }
     }
     p->flags |= INVALIDATE_CACHE; /* orthoscopic */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     SendToPymol(p, "set orthoscopic=%d\n", bool);
@@ -1192,16 +1192,16 @@
 }
 
-/* 
+/*
  * PanCmd --
  *
- *	Issue "move" commands for changes in the x and y coordinates of the
- *	camera.  The problem here is that there is no event compression.
- *	Consecutive "pan" commands are not compressed into a single
- *	directive.  The means that the pymol server will render scenes that
- *	are not used by the client.
+ * Issue "move" commands for changes in the x and y coordinates of the
+ * camera.  The problem here is that there is no event compression.
+ * Consecutive "pan" commands are not compressed into a single
+ * directive.  The means that the pymol server will render scenes that
+ * are not used by the client.
  *
- *	Need to 1) defer the "move" commands until we find the next command
- *	isn't a "pan". 2) Track the x and y coordinates as they are
- *	compressed.
+ * Need to 1) defer the "move" commands until we find the next command
+ * isn't a "pan". 2) Track the x and y coordinates as they are
+ * compressed.
  */
 static int
@@ -1216,27 +1216,27 @@
     defer = push = FALSE;
     for (i = 1; i < argc; i++) {
-	if (strcmp(argv[i],"-defer") == 0) {
-	    defer = 1;
-	} else if (strcmp(argv[i],"-push") == 0) {
-	    push = 1;
-	} else { 
-	    break;
-	}
+        if (strcmp(argv[i],"-defer") == 0) {
+            defer = 1;
+        } else if (strcmp(argv[i],"-push") == 0) {
+            push = 1;
+        } else {
+            break;
+        }
     }
     if ((Tcl_GetDouble(interp, argv[i], &x) != TCL_OK) ||
-	(Tcl_GetDouble(interp, argv[i+1], &y) != TCL_OK)) {
-	return TCL_ERROR;
-    }
-    p->flags |= INVALIDATE_CACHE;	/* pan */
+        (Tcl_GetDouble(interp, argv[i+1], &y) != TCL_OK)) {
+        return TCL_ERROR;
+    }
+    p->flags |= INVALIDATE_CACHE; /* pan */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     if ((x != 0.0f) || (y != 0.0f)) {
-	p->xPan = x * 0.05;
-	p->yPan = -y * 0.05;
-	p->flags |= PAN_PENDING;
+        p->xPan = x * 0.05;
+        p->yPan = -y * 0.05;
+        p->flags |= PAN_PENDING;
     }
     return p->status;
@@ -1280,6 +1280,6 @@
      * The extra information is contained in the token we get from the
      * molvisviewer client, the frame number, and rock offset. */
-    SendToPymol(p, "png -:%d:%d:%d,format=1\n", p->cacheId, p->frame, 
-	    p->rockOffset);
+    SendToPymol(p, "png -:%d:%d:%d,format=1\n", p->cacheId, p->frame,
+            p->rockOffset);
     p->flags &= ~(UPDATE_PENDING|FORCE_UPDATE);
     return p->status;
@@ -1288,6 +1288,6 @@
 
 static int
-PrintCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	 const char *argv[])
+PrintCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+         const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1298,34 +1298,34 @@
 
     if (argc != 5) {
-	Tcl_AppendResult(interp, "wrong # arguments: should be \"", 
-			 argv[0], " token width height color\"", (char *)NULL);
-	return TCL_ERROR;
+        Tcl_AppendResult(interp, "wrong # arguments: should be \"",
+                         argv[0], " token width height color\"", (char *)NULL);
+        return TCL_ERROR;
     }
     token = argv[1];
     if (Tcl_GetInt(interp, argv[2], &width) != TCL_OK) {
-	return TCL_ERROR;
+        return TCL_ERROR;
     }
     if (Tcl_GetInt(interp, argv[3], &height) != TCL_OK) {
-	return TCL_ERROR;
+        return TCL_ERROR;
     }
     bgcolor = argv[4];
     /* Force pymol to update the current scene. */
     if (strcmp(bgcolor, "none") == 0) {
-	SendToPymol(p, "set ray_opaque_background,off\n");
-	SendToPymol(p, "refresh\n", bgcolor);
+        SendToPymol(p, "set ray_opaque_background,off\n");
+        SendToPymol(p, "refresh\n", bgcolor);
     } else {
-	SendToPymol(p, "set ray_opaque_background,on\n");
-	SendToPymol(p, "bg_color %s\nrefresh\n", bgcolor);
+        SendToPymol(p, "set ray_opaque_background,on\n");
+        SendToPymol(p, "bg_color %s\nrefresh\n", bgcolor);
     }
     /* This is a hack. We're encoding the filename to pass extra information
      * to the MyPNGWrite routine inside of pymol. Ideally these would be
      * parameters of a new "molvispng" command that would be passed all the
-     * way through to MyPNGWrite.  
+     * way through to MyPNGWrite.
      *
      * The extra information is contained in the token we get from the
      * molvisviewer client, the frame number, and rock offset.
      */
-    SendToPymol(p, "png -:%s:0:0,width=%d,height=%d,ray=1,dpi=300\n", 
-	    token, width, height);
+    SendToPymol(p, "png -:%s:0:0,width=%d,height=%d,ray=1,dpi=300\n",
+            token, width, height);
     SendToPymol(p, "bg_color black\n");
     return p->status;
@@ -1354,8 +1354,8 @@
     p->flags |= INVALIDATE_CACHE; /* raw */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     SendToPymol(p,"%s\n", cmd);
@@ -1364,6 +1364,6 @@
 
 static int
-ResetCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	 const char *argv[])
+ResetCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+         const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1378,11 +1378,11 @@
             push = 1;
     }
-                
+
     p->flags |= INVALIDATE_CACHE; /* reset */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     SendToPymol(p, "reset\nzoom complete=1\n");
@@ -1391,6 +1391,6 @@
 
 static int
-RockCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	const char *argv[])
+RockCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+        const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1409,12 +1409,12 @@
             y = atof( argv[arg] );
     }
-                
+
     /* Does not invalidate cache. */
 
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     SendToPymol(p,"turn y, %f\n", y - p->rockOffset);
@@ -1424,6 +1424,6 @@
 
 static int
-RepresentationCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-		  const char *argv[])
+RepresentationCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+                  const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1439,92 +1439,92 @@
         if (strcmp(argv[i],"-defer") == 0 ) {
             defer = TRUE;
-	} else if (strcmp(argv[i],"-push") == 0) {
+        } else if (strcmp(argv[i],"-push") == 0) {
             push = TRUE;
-	} else if (strcmp(argv[i],"-model") == 0) {
+        } else if (strcmp(argv[i],"-model") == 0) {
             if (++i < argc) {
                 model = argv[i];
-	    }
+            }
         } else {
             rep = argv[i];
-	}
+        }
     }
     if (rep == NULL) {
-	Tcl_AppendResult(interp, "missing representation argument",
-			 (char *)NULL);
-	return TCL_ERROR;
+        Tcl_AppendResult(interp, "missing representation argument",
+                         (char *)NULL);
+        return TCL_ERROR;
     }
 
     p->flags |= INVALIDATE_CACHE; /* representation */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     if (strcmp(rep, "ballnstick") == 0) { /* Ball 'n Stick */
-	SendToPymol(p, 
-	      "set stick_color,white,%s\n"
-	      "show sticks,%s\n"
-	      "show spheres,%s\n"
-	      "hide lines,%s\n"
-	      "hide cartoon,%s\n",
-	      model, model, model, model, model);
-    } else if (strcmp(rep, "spheres") == 0) { /* spheres */    
-	SendToPymol(p, 
-	      "hide sticks,%s\n"
-	      "show spheres,%s\n"
-	      "hide lines,%s\n"
-	      "hide cartoon,%s\n"
-	      "set sphere_quality,2,%s\n"
-	      "set ambient,.2,%s\n", 
-	      model, model, model, model, model, model);
-    } else if (strcmp(rep, "none") == 0) { /* nothing */    
-	SendToPymol(p, 
-	      "hide sticks,%s\n", 
-	      "hide spheres,%s\n"
-	      "hide lines,%s\n"
-	      "hide cartoon,%s\n",
-	      model, model, model, model);
-    } else if (strcmp(rep, "sticks") == 0) { /* sticks */    
-	SendToPymol(p, 
-	      "set stick_color,white,%s\n"
-	      "show sticks,%s\n"
-	      "hide spheres,%s\n"
-	      "hide lines,%s\n"
-	      "hide cartoon,%s\n",
-	      model, model, model, model, model);
-    } else if (strcmp(rep, "lines") == 0) { /* lines */    
-	SendToPymol(p, 
-	      "hide sticks,%s\n"
-	      "hide spheres,%s\n"
-	      "show lines,%s\n"
-	      "hide cartoon,%s\n",
-	      model, model, model, model);
-    } else if (strcmp(rep, "cartoon") == 0) { /* cartoon */    
-	SendToPymol(p, 
-	      "hide sticks,%s\n"
-	      "hide spheres,%s\n"
-	      "hide lines,%s\n"
-	      "show cartoon,%s\n", 
-	      model, model, model, model);
-    } 
+        SendToPymol(p,
+              "set stick_color,white,%s\n"
+              "show sticks,%s\n"
+              "show spheres,%s\n"
+              "hide lines,%s\n"
+              "hide cartoon,%s\n",
+              model, model, model, model, model);
+    } else if (strcmp(rep, "spheres") == 0) { /* spheres */
+        SendToPymol(p,
+              "hide sticks,%s\n"
+              "show spheres,%s\n"
+              "hide lines,%s\n"
+              "hide cartoon,%s\n"
+              "set sphere_quality,2,%s\n"
+              "set ambient,.2,%s\n",
+              model, model, model, model, model, model);
+    } else if (strcmp(rep, "none") == 0) { /* nothing */
+        SendToPymol(p,
+              "hide sticks,%s\n",
+              "hide spheres,%s\n"
+              "hide lines,%s\n"
+              "hide cartoon,%s\n",
+              model, model, model, model);
+    } else if (strcmp(rep, "sticks") == 0) { /* sticks */
+        SendToPymol(p,
+              "set stick_color,white,%s\n"
+              "show sticks,%s\n"
+              "hide spheres,%s\n"
+              "hide lines,%s\n"
+              "hide cartoon,%s\n",
+              model, model, model, model, model);
+    } else if (strcmp(rep, "lines") == 0) { /* lines */
+        SendToPymol(p,
+              "hide sticks,%s\n"
+              "hide spheres,%s\n"
+              "show lines,%s\n"
+              "hide cartoon,%s\n",
+              model, model, model, model);
+    } else if (strcmp(rep, "cartoon") == 0) { /* cartoon */
+        SendToPymol(p,
+              "hide sticks,%s\n"
+              "hide spheres,%s\n"
+              "hide lines,%s\n"
+              "show cartoon,%s\n",
+              model, model, model, model);
+    }
     return p->status;
 }
 
-/* 
+/*
  * RotateCmd --
  *
- *	Issue "turn" commands for changes in the angle of the camera.  The
- *	problem here is that there is no event compression.  Consecutive
- *	"rotate" commands are not compressed into a single directive.  The
- *	means that the pymol server will render many scene that are not used
- *	by the client.
+ * Issue "turn" commands for changes in the angle of the camera.  The
+ * problem here is that there is no event compression.  Consecutive
+ * "rotate" commands are not compressed into a single directive.  The
+ * means that the pymol server will render many scene that are not used
+ * by the client.
  *
- *	Need to 1) defer the "turn" commands until we find the next command
- *	isn't a "rotate". 2) Track the rotation angles as they are compressed.
+ * Need to 1) defer the "turn" commands until we find the next command
+ * isn't a "rotate". 2) Track the rotation angles as they are compressed.
  */
 static int
-RotateCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	  const char *argv[])
+RotateCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+          const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1536,43 +1536,43 @@
     xAngle = yAngle = zAngle = 0.0f;
     for(arg = 1; arg < argc; arg++) {
-	if (strcmp(argv[arg],"-defer") == 0) {
-	    defer = 1; 
-	} else if (strcmp(argv[arg],"-push") == 0) {
-	    push = 1;
-	} else  if (varg == 1) {
-	    double value;
-	    if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
-		return TCL_ERROR;
-	    }
-	    xAngle = (float)value;
-	    varg++;
-	} else if (varg == 2) {
-	    double value;
-	    if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
-		return TCL_ERROR;
-	    }
-	    yAngle = (float)value;
-	    varg++;
-	} else if (varg == 3) {
-	    double value;
-	    if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
-		return TCL_ERROR;
-	    }
-	    zAngle = (float)value;
-	    varg++;
-	}
-    } 
+        if (strcmp(argv[arg],"-defer") == 0) {
+            defer = 1;
+        } else if (strcmp(argv[arg],"-push") == 0) {
+            push = 1;
+        } else  if (varg == 1) {
+            double value;
+            if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            xAngle = (float)value;
+            varg++;
+        } else if (varg == 2) {
+            double value;
+            if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            yAngle = (float)value;
+            varg++;
+        } else if (varg == 3) {
+            double value;
+            if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            zAngle = (float)value;
+            varg++;
+        }
+    }
     p->flags |= INVALIDATE_CACHE; /* rotate */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     if ((xAngle != 0.0f) || (yAngle != 0.0f) || (zAngle != 0.0f)) {
-	p->xAngle += xAngle;
-	p->yAngle += yAngle;
-	p->zAngle += zAngle;
-	p->flags |= ROTATE_PENDING;
+        p->xAngle += xAngle;
+        p->yAngle += yAngle;
+        p->zAngle += zAngle;
+        p->flags |= ROTATE_PENDING;
     }
     return p->status;
@@ -1580,6 +1580,6 @@
 
 static int
-ScreenCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	  const char *argv[])
+ScreenCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+          const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1591,5 +1591,5 @@
     varg = 1;
     for(i = 1; i < argc; i++) {
-        if ( strcmp(argv[i],"-defer") == 0 ) 
+        if ( strcmp(argv[i],"-defer") == 0 )
             defer = 1;
         else if ( strcmp(argv[i], "-push") == 0 )
@@ -1606,12 +1606,12 @@
     }
     if ((width < 0) || (height < 0)) {
-	return TCL_ERROR;
+        return TCL_ERROR;
     }
     p->flags |= INVALIDATE_CACHE; /* viewport */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     p->width = width;
@@ -1622,6 +1622,6 @@
 
 static int
-SphereScaleCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	   const char *argv[])
+SphereScaleCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+           const char *argv[])
 {
     int defer = 0, push = 0, i;
@@ -1635,28 +1635,28 @@
         if ( strcmp(argv[i],"-defer") == 0 ) {
             defer = 1;
-	} else if (strcmp(argv[i],"-push") == 0) {
+        } else if (strcmp(argv[i],"-push") == 0) {
             push = 1;
-	} else if (strcmp(argv[i],"-model") == 0) {
+        } else if (strcmp(argv[i],"-model") == 0) {
             if (++i < argc) {
                 model = argv[i];
-	    }
+            }
         } else {
-	    if (Tcl_GetDouble(interp, argv[i], &scale) != TCL_OK) {
-		return TCL_ERROR;
-	    }
-	}
+            if (Tcl_GetDouble(interp, argv[i], &scale) != TCL_OK) {
+                return TCL_ERROR;
+            }
+        }
     }
     p->flags |= INVALIDATE_CACHE;  /* sphere_scale */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     if (strcmp(model, "all") == 0) {
-	p->flags |= ATOM_SCALE_PENDING;
-	p->sphereScale = scale;
+        p->flags |= ATOM_SCALE_PENDING;
+        p->sphereScale = scale;
     } else {
-	SendToPymol(p, "set sphere_scale,%f,%s\n", scale, model);
+        SendToPymol(p, "set sphere_scale,%f,%s\n", scale, model);
     }
     return p->status;
@@ -1664,6 +1664,6 @@
 
 static int
-StickRadiusCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	       const char *argv[])
+StickRadiusCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+               const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1677,28 +1677,28 @@
         if (strcmp(argv[i],"-defer") == 0 ) {
             defer = 1;
-	} else if (strcmp(argv[i],"-push") == 0) {
+        } else if (strcmp(argv[i],"-push") == 0) {
             push = 1;
-	} else if (strcmp(argv[i],"-model") == 0) {
+        } else if (strcmp(argv[i],"-model") == 0) {
             if (++i < argc)
                 model = argv[i];
         } else {
-	    if (Tcl_GetDouble(interp, argv[i], &scale) != TCL_OK) {
-		return TCL_ERROR;
-	    }
-	}
+            if (Tcl_GetDouble(interp, argv[i], &scale) != TCL_OK) {
+                return TCL_ERROR;
+            }
+        }
     }
     p->flags |= INVALIDATE_CACHE;  /* stick_radius */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
 
     if (strcmp(model, "all") == 0) {
-	p->flags |= STICK_RADIUS_PENDING;
-	p->stickRadius = scale;
+        p->flags |= STICK_RADIUS_PENDING;
+        p->stickRadius = scale;
     } else {
-	SendToPymol(p, "set stick_radius,%f,%s\n", scale, model);
+        SendToPymol(p, "set stick_radius,%f,%s\n", scale, model);
     }
     return p->status;
@@ -1706,6 +1706,6 @@
 
 static int
-TransparencyCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-		const char *argv[])
+TransparencyCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+                const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1722,33 +1722,33 @@
         if ( strcmp(argv[i],"-defer") == 0 ) {
             defer = 1;
-	} else if (strcmp(argv[i],"-push") == 0) {
+        } else if (strcmp(argv[i],"-push") == 0) {
             push = 1;
-	} else if (strcmp(argv[i],"-model") == 0) {
+        } else if (strcmp(argv[i],"-model") == 0) {
             if (++i < argc) {
                 model = argv[i];
-	    }
-	} else {
-	    transparency = atof(argv[i]);
-	}
+            }
+        } else {
+            transparency = atof(argv[i]);
+        }
     }
     p->flags |= INVALIDATE_CACHE; /* transparency */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
-    } 
-    SendToPymol(p, 
-	  "set sphere_transparency,%g,%s\n"
-	  "set stick_transparency,%g,%s\n"
-	  "set cartoon_transparency,%g,%s\n",
-	  transparency, model, transparency, model, 
-	  transparency, model);
+        p->flags |= FORCE_UPDATE;
+    }
+    SendToPymol(p,
+          "set sphere_transparency,%g,%s\n"
+          "set stick_transparency,%g,%s\n"
+          "set cartoon_transparency,%g,%s\n",
+          transparency, model, transparency, model,
+          transparency, model);
     return p->status;
 }
 
 static int
-VMouseCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
-	  const char *argv[])
+VMouseCmd(ClientData clientData, Tcl_Interp *interp, int argc,
+          const char *argv[])
 {
     PymolProxy *p = clientData;
@@ -1781,10 +1781,10 @@
     }
 
-    p->flags |= INVALIDATE_CACHE;	/* vmouse */
+    p->flags |= INVALIDATE_CACHE; /* vmouse */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     SendToPymol(p, "vmouse %d,%d,%d,%d,%d\n", arg1, arg2, arg3, arg4, arg5);
@@ -1793,15 +1793,15 @@
 
 
-/* 
+/*
  * ZoomCmd --
  *
- *	Issue "move" commands for changes in the z-coordinate of the camera.
- *	The problem here is that there is no event compression.  Consecutive
- *	"zoom" commands are not compressed into a single directive.  The means
- *	that the pymol server will render scenes that are not used by the
- *	client.
+ * Issue "move" commands for changes in the z-coordinate of the camera.
+ * The problem here is that there is no event compression.  Consecutive
+ * "zoom" commands are not compressed into a single directive.  The means
+ * that the pymol server will render scenes that are not used by the
+ * client.
  *
- *	Need to 1) defer the "move" commands until we find the next command
- *	isn't a "zoom". 2) Track the z-coordinate as they are compressed.
+ * Need to 1) defer the "move" commands until we find the next command
+ * isn't a "zoom". 2) Track the z-coordinate as they are compressed.
  */
 static int
@@ -1815,35 +1815,35 @@
 
     for(i = 1; i < argc; i++) {
-	if (strcmp(argv[i],"-defer") == 0)
-	    defer = 1;
-	else if (strcmp(argv[i],"-push") == 0)
-	    push = 1;
-	else if (varg == 1) {
-	    double value;
-	    if (Tcl_GetDouble(interp, argv[i], &value) != TCL_OK) {
-		return TCL_ERROR;
-	    }
-	    factor = (float)value;
-	    varg++;
-	}
+        if (strcmp(argv[i],"-defer") == 0)
+            defer = 1;
+        else if (strcmp(argv[i],"-push") == 0)
+            push = 1;
+        else if (varg == 1) {
+            double value;
+            if (Tcl_GetDouble(interp, argv[i], &value) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            factor = (float)value;
+            varg++;
+        }
     }
     p->flags |= INVALIDATE_CACHE; /* Zoom */
     if (!defer || push) {
-	p->flags |= UPDATE_PENDING;
+        p->flags |= UPDATE_PENDING;
     }
     if (push) {
-	p->flags |= FORCE_UPDATE;
+        p->flags |= FORCE_UPDATE;
     }
     if (factor != 0.0) {
-	p->zoom = factor;
-	p->flags |= ZOOM_PENDING;
+        p->zoom = factor;
+        p->flags |= ZOOM_PENDING;
     }
     return p->status;
 }
 
-        
-
-static int
-ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr) 
+
+
+static int
+ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr)
 {
     struct timeval tv;
@@ -1860,5 +1860,5 @@
     if (result != TCL_OK) {
 #if EXEC_DEBUG
-	DEBUG("result was %s\n", Tcl_GetString(Tcl_GetObjResult(interp)));
+        DEBUG("result was %s\n", Tcl_GetString(Tcl_GetObjResult(interp)));
 #endif
     }
@@ -1876,7 +1876,7 @@
 {
     if (p->flags & VIEWPORT_PENDING) {
-	SendToPymol(p, "viewport %d,%d\n", p->width, p->height);
-	SendToPymol(p, "refresh\n");
-	p->flags &= ~VIEWPORT_PENDING;
+        SendToPymol(p, "viewport %d,%d\n", p->width, p->height);
+        SendToPymol(p, "refresh\n");
+        p->flags &= ~VIEWPORT_PENDING;
     }
 }
@@ -1887,5 +1887,5 @@
     if (p->flags & ZOOM_PENDING) {
         SendToPymol(p, "move z,%f\n", p->zoom);
-	p->flags &= ~ZOOM_PENDING;
+        p->flags &= ~ZOOM_PENDING;
     }
 }
@@ -1895,6 +1895,6 @@
 {
     if (p->flags & PAN_PENDING) {
-	SendToPymol(p, "move x,%f\nmove y,%f\n", p->xPan, p->yPan);
-	p->flags &= ~PAN_PENDING;
+        SendToPymol(p, "move x,%f\nmove y,%f\n", p->xPan, p->yPan);
+        p->flags &= ~PAN_PENDING;
     }
 }
@@ -1904,10 +1904,10 @@
 {
     if (p->flags & ROTATE_PENDING) {
-	/* Every pymol command line generates a new rendering. Execute all
-	 * three turns as a single command line. */
-	SendToPymol(p,"turn x,%f\nturn y,%f\nturn z,%f\n", p->xAngle, p->yAngle, 
-		p->zAngle);
-	p->xAngle = p->yAngle = p->zAngle = 0.0f;
-	p->flags &= ~ROTATE_PENDING;
+        /* Every pymol command line generates a new rendering. Execute all
+         * three turns as a single command line. */
+        SendToPymol(p,"turn x,%f\nturn y,%f\nturn z,%f\n", p->xAngle, p->yAngle,
+                p->zAngle);
+        p->xAngle = p->yAngle = p->zAngle = 0.0f;
+        p->flags &= ~ROTATE_PENDING;
     }
 }
@@ -1917,6 +1917,6 @@
 {
     if (p->flags & ATOM_SCALE_PENDING) {
-	SendToPymol(p, "set sphere_scale,%f,all\n", p->sphereScale);
-	p->flags &= ~ATOM_SCALE_PENDING;
+        SendToPymol(p, "set sphere_scale,%f,all\n", p->sphereScale);
+        p->flags &= ~ATOM_SCALE_PENDING;
     }
 }
@@ -1926,6 +1926,6 @@
 {
     if (p->flags & STICK_RADIUS_PENDING) {
-	SendToPymol(p, "set stick_radius,%f,all\n", p->stickRadius);
-	p->flags &= ~STICK_RADIUS_PENDING;
+        SendToPymol(p, "set stick_radius,%f,all\n", p->stickRadius);
+        p->flags &= ~STICK_RADIUS_PENDING;
     }
 }
@@ -1936,20 +1936,20 @@
     /* Handle all the pending setting changes now. */
     if (p->flags & VIEWPORT_PENDING) {
-	SetViewport(p);
+        SetViewport(p);
     }
     if (p->flags & ROTATE_PENDING) {
-	SetRotation(p);
+        SetRotation(p);
     }
     if (p->flags & PAN_PENDING) {
-	SetPan(p);
+        SetPan(p);
     }
     if (p->flags & ZOOM_PENDING) {
-	SetZoom(p);
+        SetZoom(p);
     }
     if (p->flags & ATOM_SCALE_PENDING) {
-	SetSphereScale(p);
+        SetSphereScale(p);
     }
     if (p->flags & STICK_RADIUS_PENDING) {
-	SetStickRadius(p);
+        SetStickRadius(p);
     }
 }
@@ -1963,7 +1963,7 @@
     imgPtr = malloc(sizeof(Image) + dataLength);
     if (imgPtr == NULL) {
-	ERROR("can't allocate image of %lu bytes", 
-	      (unsigned long)(sizeof(Image) + dataLength));
-	abort();
+        ERROR("can't allocate image of %lu bytes",
+              (unsigned long)(sizeof(Image) + dataLength));
+        abort();
     }
     imgPtr->prevPtr = imgPtr->nextPtr = NULL;
@@ -1974,9 +1974,9 @@
 #endif
     if (listPtr->headPtr != NULL) {
-	listPtr->headPtr->prevPtr = imgPtr;
+        listPtr->headPtr->prevPtr = imgPtr;
     }
     imgPtr->nextPtr = listPtr->headPtr;
     if (listPtr->tailPtr == NULL) {
-	listPtr->tailPtr = imgPtr;
+        listPtr->tailPtr = imgPtr;
     }
     listPtr->headPtr = imgPtr;
@@ -1996,60 +1996,60 @@
 WriteImages(ImageList *listPtr, int fd)
 {
-    Image *imgPtr, *prevPtr; 
+    Image *imgPtr, *prevPtr;
 
     if (listPtr->tailPtr == NULL) {
-	ERROR("Should not be here: no image available to write");
-	return;
+        ERROR("Should not be here: no image available to write");
+        return;
     }
 #if WRITE_DEBUG
-	DEBUG("Entering WriteImages");
+        DEBUG("Entering WriteImages");
 #endif
     for (imgPtr = listPtr->tailPtr; imgPtr != NULL; imgPtr = prevPtr) {
-	ssize_t bytesLeft;
-
-	assert(imgPtr->nextPtr == NULL);
-	prevPtr = imgPtr->prevPtr;
+        ssize_t bytesLeft;
+
+        assert(imgPtr->nextPtr == NULL);
+        prevPtr = imgPtr->prevPtr;
 #if WRITE_DEBUG
-	DEBUG("WriteImages: image %d of %d bytes.", imgPtr->id, 
-	      imgPtr->bytesLeft);
-#endif
-	for (bytesLeft = imgPtr->bytesLeft; bytesLeft > 0; /*empty*/) {
-	    ssize_t numWritten;
+        DEBUG("WriteImages: image %d of %d bytes.", imgPtr->id,
+              imgPtr->bytesLeft);
+#endif
+        for (bytesLeft = imgPtr->bytesLeft; bytesLeft > 0; /*empty*/) {
+            ssize_t numWritten;
 #if WRITE_DEBUG
-	    DEBUG("image %d: bytesLeft=%d", imgPtr->id, bytesLeft);
-#endif
-	    numWritten = write(fd, imgPtr->data + imgPtr->numWritten, bytesLeft);
+            DEBUG("image %d: bytesLeft=%d", imgPtr->id, bytesLeft);
+#endif
+            numWritten = write(fd, imgPtr->data + imgPtr->numWritten, bytesLeft);
 #if WRITE_DEBUG
-	    DEBUG("image %d: wrote %d bytes.", imgPtr->id, numWritten);
-#endif
-	    if (numWritten < 0) {
-	        ERROR("Error writing fd=%d, %s", fd, strerror(errno));
+            DEBUG("image %d: wrote %d bytes.", imgPtr->id, numWritten);
+#endif
+            if (numWritten < 0) {
+                ERROR("Error writing fd=%d, %s", fd, strerror(errno));
 #if WRITE_DEBUG
-		DEBUG("Abnormal exit WriteImages");
-#endif
-		return;
-	    }
-	    bytesLeft -= numWritten;
-	    if (bytesLeft > 0) {
+                DEBUG("Abnormal exit WriteImages");
+#endif
+                return;
+            }
+            bytesLeft -= numWritten;
+            if (bytesLeft > 0) {
 #if WRITE_DEBUG
-		DEBUG("image %d, wrote a short buffer, %d bytes left.", 
-		      imgPtr->id, bytesLeft);
-#endif
-		/* Wrote a short buffer, means we would block. */
-		imgPtr->numWritten += numWritten;
-		imgPtr->bytesLeft = bytesLeft;
+                DEBUG("image %d, wrote a short buffer, %d bytes left.",
+                      imgPtr->id, bytesLeft);
+#endif
+                /* Wrote a short buffer, means we would block. */
+                imgPtr->numWritten += numWritten;
+                imgPtr->bytesLeft = bytesLeft;
 #if WRITE_DEBUG
-		DEBUG("Abnormal exit WriteImages");
-#endif
-		return;
-	    }
-	    imgPtr->numWritten += numWritten;
-	}
-	/* Check if image is on the head.  */
-	listPtr->tailPtr = prevPtr;
-	if (prevPtr != NULL) {
-	    prevPtr->nextPtr = NULL;
-	}
-	FreeImage(imgPtr);
+                DEBUG("Abnormal exit WriteImages");
+#endif
+                return;
+            }
+            imgPtr->numWritten += numWritten;
+        }
+        /* Check if image is on the head.  */
+        listPtr->tailPtr = prevPtr;
+        if (prevPtr != NULL) {
+            prevPtr->nextPtr = NULL;
+        }
+        FreeImage(imgPtr);
     }
     listPtr->headPtr = NULL;
@@ -2061,5 +2061,5 @@
 
 static void
-ChildHandler(int sigNum) 
+ChildHandler(int sigNum)
 {
     ERROR("pymol (%d) died unexpectedly", stats.pid);
@@ -2074,30 +2074,30 @@
 
 static CmdProc cmdProcs[] = {
-    { "cartoon",        CartoonCmd	  },       
-    { "cartoontrace",   CartoonTraceCmd	  },  
-    { "clientinfo",     ClientInfoCmd     }, 
-    { "disable",        DisableCmd	  },       
-    { "enable",         EnableCmd	  },        
-    { "frame",          FrameCmd          },         
-    { "label",          LabelCmd          },         
-    { "loadpdb",        LoadPDBCmd	  },       
-    { "orthoscopic",    OrthoscopicCmd	  },   
-    { "pan",            PanCmd		  },           
-    { "png",            PngCmd		  },           
-    { "ppm",            PpmCmd		  },           
-    { "print",          PrintCmd          },         
-    { "raw",            RawCmd		  },           
+    { "cartoon",        CartoonCmd        },
+    { "cartoontrace",   CartoonTraceCmd   },
+    { "clientinfo",     ClientInfoCmd     },
+    { "disable",        DisableCmd        },
+    { "enable",         EnableCmd         },
+    { "frame",          FrameCmd          },
+    { "label",          LabelCmd          },
+    { "loadpdb",        LoadPDBCmd        },
+    { "orthoscopic",    OrthoscopicCmd    },
+    { "pan",            PanCmd            },
+    { "png",            PngCmd            },
+    { "ppm",            PpmCmd            },
+    { "print",          PrintCmd          },
+    { "raw",            RawCmd            },
     { "representation", RepresentationCmd },
-    { "reset",          ResetCmd          },         
-    { "rock",           RockCmd           },          
-    { "rotate",         RotateCmd         },        
-    { "screen",         ScreenCmd         },        
-    { "spherescale",    SphereScaleCmd    },   
-    { "stickradius",    StickRadiusCmd    },   
-    { "transparency",   TransparencyCmd   },  
-    { "viewport",       ScreenCmd         },        
-    { "vmouse",         VMouseCmd         },        
-    { "zoom",           ZoomCmd           },          
-    { NULL,	        NULL              }
+    { "reset",          ResetCmd          },
+    { "rock",           RockCmd           },
+    { "rotate",         RotateCmd         },
+    { "screen",         ScreenCmd         },
+    { "spherescale",    SphereScaleCmd    },
+    { "stickradius",    StickRadiusCmd    },
+    { "transparency",   TransparencyCmd   },
+    { "viewport",       ScreenCmd         },
+    { "vmouse",         VMouseCmd         },
+    { "zoom",           ZoomCmd           },
+    { NULL,             NULL              }
 };
 
@@ -2105,5 +2105,5 @@
 InitProxy(PymolProxy *p, char *const *argv)
 {
-    int sin[2], sout[2];		/* Pipes to connect to server. */
+    int sin[2], sout[2]; /* Pipes to connect to server. */
     pid_t child;
     struct timeval end;
@@ -2131,41 +2131,41 @@
     }
 
-    if (child == 0) {			/* Child process */
+    if (child == 0) {  /* Child process */
         int f;
-	char tmpname[200];
-
-        /* 
+        char tmpname[200];
+
+        /*
          * Create a new process group, so we can later kill this process and
          * all its children without affecting the process that created this
          * one.
          */
-        setpgid(child, 0); 
-        
-        /* Redirect stdin, stdout, and stderr to pipes before execing */ 
-
-        dup2(sin[0],  0);		/* Server standard input */
-        dup2(sout[1], 1);		/* Server standard output */
-
-	/* Redirect child's stderr to a log file. */
-	sprintf(tmpname, "%s/PYMOL-%d-stderr.XXXXXX", LOGDIR, getpid());
-	f = mkstemp(tmpname);
-	if (f < 0) {
-	    ERROR("can't open file `%s' to capture pymol stderr: %s", tmpname, 
-		  strerror(errno));
-	    exit(1);
-	}
-        dup2(f, 2);			/* Redirect stderr to a log file */
-        
-	/* Close all other descriptors  */        
-	for (f = 3; f < FD_SETSIZE; f++) {
+        setpgid(child, 0);
+
+        /* Redirect stdin, stdout, and stderr to pipes before execing */
+
+        dup2(sin[0],  0); /* Server standard input */
+        dup2(sout[1], 1); /* Server standard output */
+
+        /* Redirect child's stderr to a log file. */
+        sprintf(tmpname, "%s/PYMOL-%d-stderr.XXXXXX", LOGDIR, getpid());
+        f = mkstemp(tmpname);
+        if (f < 0) {
+            ERROR("can't open file `%s' to capture pymol stderr: %s", tmpname,
+                  strerror(errno));
+            exit(1);
+        }
+        dup2(f, 2);  /* Redirect stderr to a log file */
+
+        /* Close all other descriptors  */
+        for (f = 3; f < FD_SETSIZE; f++) {
             close(f);
-	}
+        }
         INFO("attempting to start \"%s\"", argv[0]);
         execvp(argv[0], argv);
         ERROR("can't exec `%s': %s", argv[0], strerror(errno));
-	exit(-1);
+        exit(-1);
     } else {
-	pymolIsAlive = TRUE;
-	signal(SIGCHLD, ChildHandler);
+        pymolIsAlive = TRUE;
+        signal(SIGCHLD, ChildHandler);
     }
     stats.pid = child;
@@ -2191,17 +2191,17 @@
     /* Create safe interpreter and add pymol-specific commands to it. */
     {
-	Tcl_Interp *interp;
-	CmdProc *cp;
-
-	interp = Tcl_CreateInterp();
-	Tcl_MakeSafe(interp);
-
-	for (cp = cmdProcs; cp->name != NULL; cp++) {
+        Tcl_Interp *interp;
+        CmdProc *cp;
+
+        interp = Tcl_CreateInterp();
+        Tcl_MakeSafe(interp);
+
+        for (cp = cmdProcs; cp->name != NULL; cp++) {
 #if DEBUG
-	    DEBUG("Adding command %s\n", cp->name);
-#endif
-	    Tcl_CreateCommand(interp, cp->name, cp->proc, p, NULL);
-	}
-	p->interp = interp;
+            DEBUG("Adding command %s\n", cp->name);
+#endif
+            Tcl_CreateCommand(interp, cp->name, cp->proc, p, NULL);
+        }
+        p->interp = interp;
     }
     gettimeofday(&end, NULL);
@@ -2236,33 +2236,33 @@
     DEBUG("attempting to signal (SIGTERM) pymol server.");
 #endif
-    kill(-p->pid, SIGTERM);		// Kill process group
+    kill(-p->pid, SIGTERM); /* Kill process group */
     alarm(5);
-    
+
 #if DEBUG
     DEBUG("Waiting for pymol server to exit after SIGTERM");
 #endif
     if (waitpid(p->pid, &result, 0) < 0) {
-	if (errno != ECHILD) {
-	    ERROR("error waiting on pymol server to exit after SIGTERM: %s", 
-		  strerror(errno));
-	}
+        if (errno != ECHILD) {
+            ERROR("error waiting on pymol server to exit after SIGTERM: %s",
+                  strerror(errno));
+        }
     }
     status = -1;
     while ((status == -1) && (errno == EINTR)) {
 #if DEBUG
-	DEBUG("Attempting to signal (SIGKILL) pymol server.");
-#endif
-	kill(-p->pid, SIGKILL);		// Kill process group
-	alarm(10);
+        DEBUG("Attempting to signal (SIGKILL) pymol server.");
+#endif
+        kill(-p->pid, SIGKILL); /* Kill process group */
+        alarm(10);
 #if DEBUG
-	DEBUG("Waiting for pymol server to exit after SIGKILL");
-#endif
-	status = waitpid(p->pid, &result, 0);
-	alarm(0); 
+        DEBUG("Waiting for pymol server to exit after SIGKILL");
+#endif
+        status = waitpid(p->pid, &result, 0);
+        alarm(0);
     }
     INFO("pymol server process ended (result=%d)", result);
 
     if (WIFEXITED(result)) {
-	result = WEXITSTATUS(result);
+        result = WEXITSTATUS(result);
     }
     return result;
@@ -2282,62 +2282,62 @@
     Tcl_DStringInit(&command);
     while (pymolIsAlive) {
-	tvPtr = NULL;
+        tvPtr = NULL;
 #if READ_DEBUG
-	DEBUG("Start I/O set");
-#endif
-	while ((pymolIsAlive) && (WaitForNextLine(&p->client, tvPtr))) {
-	    size_t numBytes;
-	    const char *line;
-	    int status;
-
-	    status = GetLine(&p->client, &numBytes, &line);
-	    if (status != BUFFER_OK) {
-		ERROR("can't read client stdout (numBytes=%d): %s\n", numBytes,
-		      strerror(errno));
-		goto done;
-	    }
-	    Tcl_DStringAppend(&command, line, numBytes);
-	    if (Tcl_CommandComplete(Tcl_DStringValue(&command))) {
-		int result;
-		    
-		/* May execute more than one command. */
-		result = ExecuteCommand(p->interp, &command);
-		if (result == TCL_BREAK) {
+        DEBUG("Start I/O set");
+#endif
+        while ((pymolIsAlive) && (WaitForNextLine(&p->client, tvPtr))) {
+            size_t numBytes;
+            const char *line;
+            int status;
+
+            status = GetLine(&p->client, &numBytes, &line);
+            if (status != BUFFER_OK) {
+                ERROR("can't read client stdout (numBytes=%d): %s\n", numBytes,
+                      strerror(errno));
+                goto done;
+            }
+            Tcl_DStringAppend(&command, line, numBytes);
+            if (Tcl_CommandComplete(Tcl_DStringValue(&command))) {
+                int result;
+
+                /* May execute more than one command. */
+                result = ExecuteCommand(p->interp, &command);
+                if (result == TCL_BREAK) {
 #if READ_DEBUG
-		    DEBUG("TCL_BREAK found");
-#endif
-		    break;		/* This was caused by a "imgflush"
+                    DEBUG("TCL_BREAK found");
+#endif
+                    break;              /* This was caused by a "imgflush"
 					 * command. Break out of the read
 					 * loop and allow a new image to be
 					 * rendered. */
-		}
-		if (p->flags & FORCE_UPDATE) {
+                }
+                if (p->flags & FORCE_UPDATE) {
 #if READ_DEBUG
-		    DEBUG("FORCE_UPDATE set");
-#endif
-		    break;
-		}
-	    }
-	    tv.tv_sec = 0L;
-	    tv.tv_usec = 0L;		/* On successive reads, we break
+                    DEBUG("FORCE_UPDATE set");
+#endif
+                    break;
+                }
+            }
+            tv.tv_sec = 0L;
+            tv.tv_usec = 0L;		/* On successive reads, we break
 					 * out if no data is available. */
-	    tvPtr = &tv;			
-	}
+            tvPtr = &tv;
+        }
 #if READ_DEBUG
-	DEBUG("Finish I/O set");
-#endif
-	/* Handle all the pending setting changes now. */
-	UpdateSettings(p);
-
-	/* We might want to refresh the image if we're not currently
-	 * transmitting an image back to the client. The image will be
-	 * refreshed after the image has been completely transmitted. */
-	if (p->flags & UPDATE_PENDING) {
+        DEBUG("Finish I/O set");
+#endif
+        /* Handle all the pending setting changes now. */
+        UpdateSettings(p);
+
+        /* We might want to refresh the image if we're not currently
+         * transmitting an image back to the client. The image will be
+         * refreshed after the image has been completely transmitted. */
+        if (p->flags & UPDATE_PENDING) {
 #if READ_DEBUG
-	    DEBUG("calling ppm because of update");
-#endif
-	    Tcl_Eval(p->interp, "ppm");
-	    p->flags &= ~(UPDATE_PENDING|FORCE_UPDATE);
-	}
+            DEBUG("calling ppm because of update");
+#endif
+            Tcl_Eval(p->interp, "ppm");
+            p->flags &= ~(UPDATE_PENDING|FORCE_UPDATE);
+        }
     }
  done:
@@ -2359,67 +2359,67 @@
     list.headPtr = list.tailPtr = NULL;
     while (pymolIsAlive) {
-	while (WaitForNextLine(bp, NULL)) {
-	    Image *imgPtr;
-	    const char *line;
-	    char header[200];
-	    size_t len;
-	    int numBytes;
-	    size_t hdrLength;
-	    int frameNum, rockOffset;
-	    char cacheId[200];
-
-	    /* Keep reading lines untils we find a "image follows:" line */
-	    if (GetLine(bp, &len, &line) != BUFFER_OK) {
+        while (WaitForNextLine(bp, NULL)) {
+            Image *imgPtr;
+            const char *line;
+            char header[200];
+            size_t len;
+            int numBytes;
+            size_t hdrLength;
+            int frameNum, rockOffset;
+            char cacheId[200];
+
+            /* Keep reading lines untils we find a "image follows:" line */
+            if (GetLine(bp, &len, &line) != BUFFER_OK) {
 #if WRITE_DEBUG
-		DEBUG("Leaving Writer thread");
-#endif
-		return NULL;
-	    }
+                DEBUG("Leaving Writer thread");
+#endif
+                return NULL;
+            }
 #if WRITE_DEBUG
-	    DEBUG("Writer: line found is %s\n", line);
-#endif
-	    if (strncmp(line, "image follows: ", 15) != 0) {
-		continue;
-	    }
-	    if (sscanf(line, "image follows: %d %s %d %d\n", &numBytes, cacheId,
-		       &frameNum, &rockOffset) != 4) {
-		ERROR("can't get # bytes from \"%s\"", line);
-		DEBUG("Leaving Writer thread");
-		return NULL;
-	    } 
+            DEBUG("Writer: line found is %s\n", line);
+#endif
+            if (strncmp(line, "image follows: ", 15) != 0) {
+                continue;
+            }
+            if (sscanf(line, "image follows: %d %s %d %d\n", &numBytes, cacheId,
+                       &frameNum, &rockOffset) != 4) {
+                ERROR("can't get # bytes from \"%s\"", line);
+                DEBUG("Leaving Writer thread");
+                return NULL;
+            }
 #if WRITE_DEBUG
-	    DEBUG("found image line \"%.*s\"", numBytes, line);
-#endif
-	    sprintf(header, "nv>image %d %s %d %d\n", numBytes, cacheId, 
-		    frameNum, rockOffset);
-	    hdrLength = strlen(header);
+            DEBUG("found image line \"%.*s\"", numBytes, line);
+#endif
+            sprintf(header, "nv>image %d %s %d %d\n", numBytes, cacheId,
+                    frameNum, rockOffset);
+            hdrLength = strlen(header);
 #if WRITE_DEBUG
-	    DEBUG("Queueing image numBytes=%d cacheId=%s, frameNum=%d, rockOffset=%d size=%d\n", numBytes, cacheId, frameNum, rockOffset, numBytes + hdrLength);
-#endif
-	    imgPtr = NewImage(&list, numBytes + hdrLength);
-	    memcpy(imgPtr->data, header, hdrLength);
-	    if (ReadFollowingData(bp, imgPtr->data + hdrLength, 
-			(size_t)numBytes) != BUFFER_OK) {
-		ERROR("can't read %d bytes for \"image follows\" buffer: %s", 
-		      numBytes, strerror(errno));
+            DEBUG("Queueing image numBytes=%d cacheId=%s, frameNum=%d, rockOffset=%d size=%d\n", numBytes, cacheId, frameNum, rockOffset, numBytes + hdrLength);
+#endif
+            imgPtr = NewImage(&list, numBytes + hdrLength);
+            memcpy(imgPtr->data, header, hdrLength);
+            if (ReadFollowingData(bp, imgPtr->data + hdrLength,
+                        (size_t)numBytes) != BUFFER_OK) {
+                ERROR("can't read %d bytes for \"image follows\" buffer: %s",
+                      numBytes, strerror(errno));
 #if WRITE_DEBUG
-		DEBUG("Leaving Writer thread");
-#endif
-		return NULL;
-	    }
-	    stats.numFrames++;
-	    stats.numBytes += numBytes;
-	    {
-		struct timeval tv;
-		fd_set writeFds;
-
-		tv.tv_sec = tv.tv_usec = 0L;
-		FD_ZERO(&writeFds);
-		FD_SET(CLIENT_WRITE, &writeFds);
-		if (select(CLIENT_WRITE+1, NULL, &writeFds, NULL, &tv) > 0) {
-		    WriteImages(&list, CLIENT_WRITE);
-		}
-	    }
-	}
+                DEBUG("Leaving Writer thread");
+#endif
+                return NULL;
+            }
+            stats.numFrames++;
+            stats.numBytes += numBytes;
+            {
+                struct timeval tv;
+                fd_set writeFds;
+
+                tv.tv_sec = tv.tv_usec = 0L;
+                FD_ZERO(&writeFds);
+                FD_SET(CLIENT_WRITE, &writeFds);
+                if (select(CLIENT_WRITE+1, NULL, &writeFds, NULL, &tv) > 0) {
+                    WriteImages(&list, CLIENT_WRITE);
+                }
+            }
+        }
     }
 #if WRITE_DEBUG
@@ -2440,7 +2440,7 @@
     frecord = NULL;
     if (recording) {
-	char fileName[200];
-
-	sprintf(fileName, "/tmp/pymolproxy%d.py", getpid());
+        char fileName[200];
+
+        sprintf(fileName, "/tmp/pymolproxy%d.py", getpid());
         frecord = fopen(fileName, "w");
     }
@@ -2462,5 +2462,5 @@
     if (pthread_join(thread1, NULL) < 0) {
         ERROR("Can't join reader thread: %s", strerror(errno));
-    } 
+    }
     return FreeProxy(&proxy);
 }
