Changeset 6396 for pymolproxy


Ignore:
Timestamp:
Jun 16, 2016 7:45:04 PM (8 years ago)
Author:
ldelgass
Message:

merge from pymolproxy trunk

Location:
pymolproxy/branches/1.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pymolproxy/branches/1.0

  • pymolproxy/branches/1.0/pymolproxy.c

    r4623 r6396  
    1 
     1/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    22/*
    33 * ----------------------------------------------------------------------
    4  * proxypymol2.c
     4 * proxypymol.c
    55 *
    6  *      This module creates the Tcl interface to the pymol server.  It acts as
    7  *      a go-between establishing communication between a molvisviewer widget
    8  *      and the pymol server. The communication protocol from the molvisviewer
    9  *      widget is the Tcl language.  Commands are then relayed to the pymol
    10  *      server.  Responses from the pymol server are translated into Tcl
    11  *      commands and send to the molvisviewer widget. For example, resulting
    12  *      image rendered offscreen is returned as ppm-formatted image data.
     6 * This module creates the Tcl interface to the pymol server.  It acts as
     7 * a go-between establishing communication between a molvisviewer widget
     8 * and the pymol server. The communication protocol from the molvisviewer
     9 * widget is the Tcl language.  Commands are then relayed to the pymol
     10 * server.  Responses from the pymol server are translated into Tcl
     11 * commands and send to the molvisviewer widget. For example, resulting
     12 * image rendered offscreen is returned as ppm-formatted image data.
    1313 *
    1414 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
     
    2020
    2121/*
    22  * Notes:   The proxy should not maintain any state information from the
    23  *          client, other that what it needs for event (rotate, pan, zoom,
    24  *          atom scale, bond thickness, etc.) compression.  This is because
    25  *          the connection is periodically broken (timeout, error, etc.).
    26  *          It's the responsibility of the client (molvisviewer) to restore
    27  *          the settings of the previous view.  The proxy is just a relay
    28  *          between the client and the pymol server.
     22 * Notes:
     23 *
     24 * The proxy should not maintain any state information from the
     25 * client, other that what it needs for event (rotate, pan, zoom,
     26 * atom scale, bond thickness, etc.) compression.  This is because
     27 * the connection is periodically broken (timeout, error, etc.).
     28 * It's the responsibility of the client (molvisviewer) to restore
     29 * the settings of the previous view.  The proxy is just a relay
     30 * between the client and the pymol server.
    2931 */
    3032/*
    3133 *   +--------------+          +------------+          +----------+
    32  *   |              | (stdin)  |            |  (stdin) |          | 
     34 *   |              | (stdin)  |            |  (stdin) |          |
    3335 *   |              |--------->|            |--------->|          |
    3436 *   | molvisviewer |          | pymolproxy |          | pymol    |
    3537 *   |  (client)    |          |            |          | (server) |(stderr)
    3638 *   |              | (stdout) |            | (stdout) |          |-------> file
    37  *   |              |<---------|            |<---------|          | 
     39 *   |              |<---------|            |<---------|          |
    3840 *   +--------------+          +------------+          +----------+
    39  * 
     41 *
    4042 * We're using a simple 2 thread setup: one for read client requests and
    4143 * relaying them to the pymol server, another reading pymol server output,
     
    4648 *
    4749 * Reader thread:
    48  * The communication between the pymol server and proxy is asynchronous. 
     50 * The communication between the pymol server and proxy is asynchronous.
    4951 * The proxy translates commands from the client and sends them to the
    5052 * server without waiting for a response.  It watches the server's
    51  * stdout in a separate thread snooping for image data. 
     53 * stdout in a separate thread snooping for image data.
    5254 *
    5355 * Writer thread:
    54  * The communication between the client and the proxy is also asynchronous. 
    55  * The client commands are read when they become available on the socket. 
     56 * The communication between the client and the proxy is also asynchronous.
     57 * The client commands are read when they become available on the socket.
    5658 * The proxy writes images to the client when it can, otherwise it stores
    5759 * them in a list in memory.  This should prevent deadlocks from occuring:
     
    98100static int statsFile = -1;
    99101
    100 #define WANT_DEBUG      0
    101 #define READ_DEBUG      0
    102 #define WRITE_DEBUG     0
    103 #define EXEC_DEBUG      0
     102#define WANT_DEBUG  0
     103#define READ_DEBUG  0
     104#define WRITE_DEBUG 0
     105#define EXEC_DEBUG  0
    104106
    105107#define FORCE_UPDATE            (1<<0)
     
    115117
    116118#define IO_TIMEOUT (30000)
    117 #define CLIENT_READ             STDIN_FILENO
    118 #define CLIENT_WRITE            STDOUT_FILENO
     119#define CLIENT_READ  STDIN_FILENO
     120#define CLIENT_WRITE STDOUT_FILENO
    119121
    120122#ifndef LOGDIR
    121 #define LOGDIR          "/tmp"
    122 #endif  /* LOGDIR */
     123#define LOGDIR "/tmp"
     124#endif /* LOGDIR */
    123125
    124126#define CVT2SECS(x)  ((double)(x).tv_sec) + ((double)(x).tv_usec * 1.0e-6)
     
    155157} Image;
    156158
    157 #define BUFFER_SIZE             4096
     159#define BUFFER_SIZE 4096
    158160
    159161typedef struct {
     
    174176} ReadBuffer;
    175177
    176 #define BUFFER_OK                0
    177 #define BUFFER_ERROR            -1
    178 #define BUFFER_CONTINUE         -2
    179 #define BUFFER_EOF              -3
     178#define BUFFER_OK        0
     179#define BUFFER_ERROR    -1
     180#define BUFFER_CONTINUE -2
     181#define BUFFER_EOF      -3
    180182
    181183typedef struct {
     
    203205
    204206#if WANT_DEBUG
    205 #define DEBUG(...)      if (debug) PrintToLog(__VA_ARGS__)
    206 #else 
    207 #define DEBUG(...) 
    208 #endif
    209 
    210 #define ERROR(...)      SysLog(LOG_ERR, __FILE__, __LINE__, __VA_ARGS__)
    211 #define TRACE(...)      SysLog(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
    212 #define WARN(...)       SysLog(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__)
    213 #define INFO(...)       SysLog(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
     207#define DEBUG(...) if (debug) PrintToLog(__VA_ARGS__)
     208#else
     209#define DEBUG(...)
     210#endif
     211
     212#define ERROR(...) SysLog(LOG_ERR, __FILE__, __LINE__, __VA_ARGS__)
     213#define TRACE(...) SysLog(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
     214#define WARN(...)  SysLog(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__)
     215#define INFO(...)  SysLog(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
    214216
    215217static const char *syslogLevels[] = {
    216     "emergency",                        /* System is unusable */
    217     "alert",                            /* Action must be taken immediately */
    218     "critical",                         /* Critical conditions */
    219     "error",                            /* Error conditions */
    220     "warning",                          /* Warning conditions */
    221     "notice",                           /* Normal but significant condition */
    222     "info",                             /* Informational */
    223     "debug",                            /* Debug-level messages */
     218    "emergency", /* System is unusable */
     219    "alert",     /* Action must be taken immediately */
     220    "critical",  /* Critical conditions */
     221    "error",     /* Error conditions */
     222    "warning",   /* Warning conditions */
     223    "notice",    /* Normal but significant condition */
     224    "info",      /* Informational */
     225    "debug",     /* Debug-level messages */
    224226};
    225227
     
    230232    const char *format;
    231233    va_list args;
    232    
     234
    233235    format = TCL_VARARGS_START(const char *, arg1, args);
    234236    fprintf(stderr, "pymolproxy: ");
     
    255257        s++;
    256258    }
    257     length = snprintf(message, MSG_LEN, "pymolproxy (%d) %s: %s:%d ", 
    258         getpid(), syslogLevels[priority],  s, lineNum);
     259    length = snprintf(message, MSG_LEN, "pymolproxy (%d) %s: %s:%d ",
     260        getpid(), syslogLevels[priority],  s, lineNum);
    259261    length += vsnprintf(message + length, MSG_LEN - length, fmt, lst);
    260262    message[MSG_LEN] = '\0';
    261263    if (debug) {
    262         DEBUG("%s\n", message);
     264        DEBUG("%s\n", message);
    263265    } else {
    264         syslog(priority, message, length);
     266        syslog(priority, message, length);
    265267    }
    266268}
     
    271273    const char *format;
    272274    va_list args;
    273    
     275
    274276    format = TCL_VARARGS_START(const char *, arg1, args);
    275277    vfprintf(frecord, format, args);
     
    289291        return TCL_ERROR;
    290292    }
    291    
     293
    292294    va_start(ap, format);
    293295    result = vsnprintf(buffer, BUFSIZ-1, format, ap);
    294296    va_end(ap);
    295    
     297
    296298#ifdef EXEC_DEBUG
    297299    DEBUG("to-pymol>(%s) code=%d", buffer, result);
    298300#endif
    299301    if (recording) {
    300         Record("%s\n", buffer);
    301     }
    302    
     302        Record("%s\n", buffer);
     303    }
     304
    303305    /* Write the command out to the server. */
    304306    length = strlen(buffer);
    305307    numWritten = write(proxyPtr->sin, buffer, length);
    306308    if (numWritten != length) {
    307         ERROR("short write to pymol (wrote=%d, should have been %d): %s",
    308               numWritten, length, strerror(errno));
     309        ERROR("short write to pymol (wrote=%d, should have been %d): %s",
     310              numWritten, length, strerror(errno));
    309311    }
    310312    proxyPtr->status = result;
     
    355357
    356358    if (bp->newline > 0) {
    357         return bp->newline;
     359        return bp->newline;
    358360    } else {
    359         unsigned char *p;
    360         size_t newline;
    361 
    362         p = (unsigned char *)memchr(bp->bytes + bp->mark, '\n',
    363                                     bp->fill - bp->mark);
    364         if (p == NULL) {
    365             newline = 0;
    366         } else {
    367             newline = (p - bp->bytes + 1);
    368         }
    369         bp->newline = newline;
    370         return newline;
    371     }
    372 }
    373 
    374 /** 
     361        unsigned char *p;
     362        size_t newline;
     363
     364        p = (unsigned char *)memchr(bp->bytes + bp->mark, '\n',
     365                                    bp->fill - bp->mark);
     366        if (p == NULL) {
     367            newline = 0;
     368        } else {
     369            newline = (p - bp->bytes + 1);
     370        }
     371        bp->newline = newline;
     372        return newline;
     373    }
     374}
     375
     376/**
    375377 * \brief Fills the buffer with available data.
    376  * 
    377  * Any existing data in the buffer is moved to the front of the buffer, 
     378 *
     379 * Any existing data in the buffer is moved to the front of the buffer,
    378380 * then the channel is read to fill the rest of the buffer.
    379381 *
    380382 * \return If an error occur when reading the channel, then ERROR is
    381  * returned. ENDFILE is returned on EOF.  If the buffer can't be filled, 
     383 * returned. ENDFILE is returned on EOF.  If the buffer can't be filled,
    382384 * then CONTINUE is returned.
    383385 */
    384 static int 
     386static int
    385387FillReadBuffer(ReadBuffer *bp)
    386388{
     
    389391
    390392#if READ_DEBUG
    391     DEBUG("Enter FillReadBuffer for %s: mark=%lu fill=%lu", 
    392           bp->ident, bp->mark, bp->fill);
     393    DEBUG("Enter FillReadBuffer for %s: mark=%lu fill=%lu",
     394          bp->ident, bp->mark, bp->fill);
    393395#endif
    394396    if (bp->mark >= bp->fill) {
    395         FlushReadBuffer(bp);    /* Fully consumed buffer */
     397        FlushReadBuffer(bp); /* Fully consumed buffer */
    396398    }
    397399    if (bp->mark > 0) {
     
    401403        DEBUG("memmove %lu bytes", bp->fill - bp->mark);
    402404#endif
    403         memmove(bp->bytes, bp->bytes + bp->mark, 
    404                 bp->fill - bp->mark);
     405        memmove(bp->bytes, bp->bytes + bp->mark,
     406                bp->fill - bp->mark);
    405407        bp->fill -= bp->mark;
    406408        bp->mark = 0;
     
    415417        /* EOF */
    416418#if READ_DEBUG
    417         DEBUG("EOF found reading %s buffer (fill=%d): ", 
    418               bp->ident, bp->fill);
     419        DEBUG("EOF found reading %s buffer (fill=%d): ",
     420              bp->ident, bp->fill);
    419421#endif
    420422        return BUFFER_EOF;
     
    440442 * \brief Read the requested number of bytes from the buffer.
    441443
    442  * Fails if the requested number of bytes are not immediately 
    443  * available. Never should be short. 
     444 * Fails if the requested number of bytes are not immediately
     445 * available. Never should be short.
    444446 */
    445447static int
     
    469471        /* Didn't get enough bytes, need to read some more. */
    470472        bp->lastStatus = FillReadBuffer(bp);
    471         if ((bp->lastStatus == BUFFER_ERROR) || 
    472             (bp->lastStatus == BUFFER_EOF)) {
     473        if ((bp->lastStatus == BUFFER_ERROR) ||
     474            (bp->lastStatus == BUFFER_EOF)) {
    473475            return bp->lastStatus;
    474476        }
     
    477479}
    478480
    479 /** 
     481/**
    480482 * \brief Returns the next available line (terminated by a newline)
    481  * 
     483 *
    482484 * If insufficient data is in the buffer, then the channel is
    483485 * read for more data.  If reading the channel results in a
     
    504506            *numBytesPtr = newline - bp->mark;
    505507            bp->mark = newline;
    506             bp->newline = 0;
     508            bp->newline = 0;
    507509            return BUFFER_OK;
    508510        }
     
    537539
    538540    if (IsLineAvailable(bp)) {
    539         return 1;
     541        return 1;
    540542    }
    541543    FD_ZERO(&readFds);
     
    553555
    554556#ifndef STATSDIR
    555 #define STATSDIR        "/var/tmp/visservers"
     557#define STATSDIR "/var/tmp/visservers"
    556558#endif  /*STATSDIR*/
    557559
     
    569571
    570572    if ((string == NULL) || (statsFile >= 0)) {
    571         return statsFile;
     573        return statsFile;
    572574    }
    573575    /* By itself the client's key/value pairs aren't unique.  Add in the
     
    597599    Tcl_DStringFree(&ds);
    598600    if (statsFile < 0) {
    599         ERROR("can't open \"%s\": %s", fileName, strerror(errno));
    600         return -1;
     601        ERROR("can't open \"%s\": %s", fileName, strerror(errno));
     602        return -1;
    601603    }
    602604    return statsFile;
     
    608610
    609611    if (f >= 0) {
    610         ssize_t numWritten;
     612        ssize_t numWritten;
    611613
    612614        numWritten = write(f, s, length);
     
    619621
    620622static int
    621 ServerStats(int code) 
     623ServerStats(int code)
    622624{
    623625    double start, finish;
     
    628630
    629631    {
    630         struct timeval tv;
    631 
    632         /* Get ending time.  */
    633         gettimeofday(&tv, NULL);
    634         finish = CVT2SECS(tv);
    635         tv = stats.start;
    636         start = CVT2SECS(tv);
    637     }
    638     /* 
     632        struct timeval tv;
     633
     634        /* Get ending time.  */
     635        gettimeofday(&tv, NULL);
     636        finish = CVT2SECS(tv);
     637        tv = stats.start;
     638        start = CVT2SECS(tv);
     639    }
     640    /*
    639641     * Session information:
    640642     *   - Name of render server
     
    649651     *   - Total elapsed time of session
    650652     *   - Exit code of vizserver
    651      *   - User time 
     653     *   - User time
    652654     *   - System time
    653      *   - User time of children 
    654      *   - System time of children 
    655      */ 
     655     *   - User time of children
     656     *   - System time of children
     657     */
    656658
    657659    Tcl_DStringInit(&ds);
    658    
     660
    659661    Tcl_DStringAppendElement(&ds, "render_stop");
    660662    /* renderer */
     
    704706    Tcl_DStringAppendElement(&ds, buf);
    705707    {
    706         long clocksPerSec = sysconf(_SC_CLK_TCK);
    707         double clockRes = 1.0 / clocksPerSec;
    708         struct tms tms;
    709 
    710         memset(&tms, 0, sizeof(tms));
    711         times(&tms);
    712         /* utime */
    713         Tcl_DStringAppendElement(&ds, "utime");
    714         sprintf(buf, "%g", tms.tms_utime * clockRes);
    715         Tcl_DStringAppendElement(&ds, buf);
    716         /* stime */
    717         Tcl_DStringAppendElement(&ds, "stime");
    718         sprintf(buf, "%g", tms.tms_stime * clockRes);
    719         Tcl_DStringAppendElement(&ds, buf);
    720         /* cutime */
    721         Tcl_DStringAppendElement(&ds, "cutime");
    722         sprintf(buf, "%g", tms.tms_cutime * clockRes);
    723         Tcl_DStringAppendElement(&ds, buf);
    724         /* cstime */
    725         Tcl_DStringAppendElement(&ds, "cstime");
    726         sprintf(buf, "%g", tms.tms_cstime * clockRes);
    727         Tcl_DStringAppendElement(&ds, buf);
     708        long clocksPerSec = sysconf(_SC_CLK_TCK);
     709        double clockRes = 1.0 / clocksPerSec;
     710        struct tms tms;
     711
     712        memset(&tms, 0, sizeof(tms));
     713        times(&tms);
     714        /* utime */
     715        Tcl_DStringAppendElement(&ds, "utime");
     716        sprintf(buf, "%g", tms.tms_utime * clockRes);
     717        Tcl_DStringAppendElement(&ds, buf);
     718        /* stime */
     719        Tcl_DStringAppendElement(&ds, "stime");
     720        sprintf(buf, "%g", tms.tms_stime * clockRes);
     721        Tcl_DStringAppendElement(&ds, buf);
     722        /* cutime */
     723        Tcl_DStringAppendElement(&ds, "cutime");
     724        sprintf(buf, "%g", tms.tms_cutime * clockRes);
     725        Tcl_DStringAppendElement(&ds, buf);
     726        /* cstime */
     727        Tcl_DStringAppendElement(&ds, "cstime");
     728        sprintf(buf, "%g", tms.tms_cstime * clockRes);
     729        Tcl_DStringAppendElement(&ds, buf);
    728730    }
    729731    Tcl_DStringAppend(&ds, "\n", -1);
     
    737739
    738740static int
    739 CartoonCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    740            const char *argv[])
     741CartoonCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     742           const char *argv[])
    741743{
    742744    PymolProxy *p = clientData;
     
    751753        if (strcmp(argv[i],"-defer") == 0) {
    752754            defer = TRUE;
    753         } else if (strcmp(argv[i],"-push") == 0) {
     755        } else if (strcmp(argv[i],"-push") == 0) {
    754756            push = TRUE;
    755         } else if (strcmp(argv[i],"-model") == 0) {
     757        } else if (strcmp(argv[i],"-model") == 0) {
    756758            if (++i < argc) {
    757759                model = argv[i];
    758             }
    759         } else {
    760             if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
    761                 return TCL_ERROR;
    762             }
    763         }
    764     }
    765     p->flags |= INVALIDATE_CACHE;       /* cartoon */
     760            }
     761        } else {
     762            if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
     763                return TCL_ERROR;
     764            }
     765        }
     766    }
     767    p->flags |= INVALIDATE_CACHE; /* cartoon */
    766768    if (!defer || push) {
    767         p->flags |= UPDATE_PENDING;
     769        p->flags |= UPDATE_PENDING;
    768770    }
    769771    if (push) {
    770         p->flags |= FORCE_UPDATE;
     772        p->flags |= FORCE_UPDATE;
    771773    }
    772774    if (bool) {
    773         SendToPymol(p, "show cartoon,%s\n", model);
     775        SendToPymol(p, "show cartoon,%s\n", model);
    774776    } else {
    775         SendToPymol(p, "hide cartoon,%s\n", model);
     777        SendToPymol(p, "hide cartoon,%s\n", model);
    776778    }
    777779    return p->status;
     
    779781
    780782static int
    781 CartoonTraceCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    782                 const char *argv[])
     783CartoonTraceCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     784                const char *argv[])
    783785{
    784786    PymolProxy *p = clientData;
     
    792794        if (strcmp(argv[i],"-defer") == 0) {
    793795            defer = TRUE;
    794         } else if (strcmp(argv[i],"-push") == 0) {
     796        } else if (strcmp(argv[i],"-push") == 0) {
    795797            push = TRUE;
    796         } else if (strcmp(argv[i],"-model") == 0) {
     798        } else if (strcmp(argv[i],"-model") == 0) {
    797799            if (++i < argc) {
    798800                model = argv[i];
    799             }
    800         } else {
    801             if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
    802                 return TCL_ERROR;
    803             }
    804         }
     801            }
     802        } else {
     803            if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
     804                return TCL_ERROR;
     805            }
     806        }
    805807    }
    806808    p->flags |= INVALIDATE_CACHE; /* cartoon_trace  */
    807809    if (!defer || push) {
    808         p->flags |= UPDATE_PENDING;
     810        p->flags |= UPDATE_PENDING;
    809811    }
    810812    if (push) {
    811         p->flags |= FORCE_UPDATE;
     813        p->flags |= FORCE_UPDATE;
    812814    }
    813815    SendToPymol(p, "set cartoon_trace,%d,%s\n", bool, model);
     
    816818
    817819static int
    818 DisableCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    819            const char *argv[])
     820DisableCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     821           const char *argv[])
    820822{
    821823    PymolProxy *p = clientData;
     
    834836    }
    835837
    836     p->flags |= INVALIDATE_CACHE;       /* disable */
     838    p->flags |= INVALIDATE_CACHE; /* disable */
    837839    if (!defer || push) {
    838         p->flags |= UPDATE_PENDING;
     840        p->flags |= UPDATE_PENDING;
    839841    }
    840842    if (push) {
    841         p->flags |= FORCE_UPDATE;
     843        p->flags |= FORCE_UPDATE;
    842844    }
    843845    SendToPymol(p, "disable %s\n", model);
     
    847849
    848850static int
    849 EnableCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    850           const char *argv[])
     851EnableCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     852          const char *argv[])
    851853{
    852854    PymolProxy *p = clientData;
     
    860862        if (strcmp(argv[i],"-defer") == 0) {
    861863            defer = TRUE;
    862         } else if (strcmp(argv[i], "-push") == 0) {
     864        } else if (strcmp(argv[i], "-push") == 0) {
    863865            push = TRUE;
    864         } else {
     866        } else {
    865867            model = argv[i];
    866         }
     868        }
    867869    }
    868870    p->flags |= INVALIDATE_CACHE; /* enable */
    869871    if (!defer || push) {
    870         p->flags |= UPDATE_PENDING;
     872        p->flags |= UPDATE_PENDING;
    871873    }
    872874    if (push) {
    873         p->flags |= FORCE_UPDATE;
     875        p->flags |= FORCE_UPDATE;
    874876    }
    875877    SendToPymol(p, "enable %s\n", model);
     
    878880
    879881static int
    880 FrameCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    881         const char *argv[])
     882FrameCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     883        const char *argv[])
    882884{
    883885    PymolProxy *p = clientData;
     
    887889    frame = 0;
    888890    push = defer = FALSE;
    889     for(i = 1; i < argc; i++) { 
     891    for(i = 1; i < argc; i++) {
    890892        if (strcmp(argv[i],"-defer") == 0) {
    891893            defer = TRUE;
    892         } else if (strcmp(argv[i],"-push") == 0) {
     894        } else if (strcmp(argv[i],"-push") == 0) {
    893895            push = TRUE;
    894         } else {
     896        } else {
    895897            frame = atoi(argv[i]);
    896         }
     898        }
    897899    }
    898900    if (!defer || push) {
    899         p->flags |= UPDATE_PENDING;
     901        p->flags |= UPDATE_PENDING;
    900902    }
    901903    if (push) {
    902         p->flags |= FORCE_UPDATE;
     904        p->flags |= FORCE_UPDATE;
    903905    }
    904906    p->frame = frame;
     
    910912}
    911913
    912 /* 
     914/*
    913915 * ClientInfoCmd --
    914916 *
    915  *       
    916  *      clientinfo path list
     917 * clientinfo path list
    917918 */
    918919static int
    919 ClientInfoCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    920               const char *argv[])
     920ClientInfoCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     921              const char *argv[])
    921922{
    922923    Tcl_DString ds;
     
    929930
    930931    if (argc != 2) {
    931         Tcl_AppendResult(interp, "wrong # of arguments: should be \"", argv[0],
    932                 " list\"", (char *)NULL);
    933         return TCL_ERROR;
     932        Tcl_AppendResult(interp, "wrong # of arguments: should be \"", argv[0],
     933                " list\"", (char *)NULL);
     934        return TCL_ERROR;
    934935    }
    935936    /* Use the initial client key value pairs as the parts for a generating
     
    937938    f = GetStatsFile(argv[1]);
    938939    if (f < 0) {
    939         Tcl_AppendResult(interp, "can't open stats file: ",
     940        Tcl_AppendResult(interp, "can't open stats file: ",
    940941                         Tcl_PosixError(interp), (char *)NULL);
    941         return TCL_ERROR;
     942        return TCL_ERROR;
    942943    }
    943944    Tcl_DStringInit(&ds);
     
    947948        /* renderer */
    948949        Tcl_DStringAppendElement(&ds, "renderer");
    949         Tcl_DStringAppendElement(&ds, "pymol");
     950        Tcl_DStringAppendElement(&ds, "pymol");
    950951        /* pid */
    951         Tcl_DStringAppendElement(&ds, "pid");
    952         sprintf(buf, "%d", getpid());
    953         Tcl_DStringAppendElement(&ds, buf);
     952        Tcl_DStringAppendElement(&ds, "pid");
     953        sprintf(buf, "%d", getpid());
     954        Tcl_DStringAppendElement(&ds, buf);
    954955        /* host */
    955956        Tcl_DStringAppendElement(&ds, "host");
    956         gethostname(buf, BUFSIZ-1);
    957         buf[BUFSIZ-1] = '\0';
    958         Tcl_DStringAppendElement(&ds, buf);
     957        gethostname(buf, BUFSIZ-1);
     958        buf[BUFSIZ-1] = '\0';
     959        Tcl_DStringAppendElement(&ds, buf);
    959960    } else {
    960961        Tcl_DStringAppendElement(&ds, "render_info");
     
    972973    /* Client arguments. */
    973974    if (Tcl_SplitList(interp, argv[1], &numElems, &elems) != TCL_OK) {
    974         return TCL_ERROR;
     975        return TCL_ERROR;
    975976    }
    976977    for (i = 0; i < numElems; i++) {
    977         Tcl_DStringAppendElement(&ds, elems[i]);
     978        Tcl_DStringAppendElement(&ds, elems[i]);
    978979    }
    979980    free(elems);
     
    985986
    986987static int
    987 LabelCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    988         const char *argv[])
     988LabelCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     989        const char *argv[])
    989990{
    990991    PymolProxy *p = clientData;
     
    10001001        if (strcmp(argv[i],"-defer") == 0) {
    10011002            defer = TRUE;
    1002         } else if (strcmp(argv[i],"-push") == 0) {
     1003        } else if (strcmp(argv[i],"-push") == 0) {
    10031004            push = TRUE;
    1004         } else if (strcmp(argv[i],"-model") == 0) {
     1005        } else if (strcmp(argv[i],"-model") == 0) {
    10051006            if (++i < argc) {
    10061007                model = argv[i];
    1007             }
    1008         } else if (strcmp(argv[i],"-size") == 0) {
     1008            }
     1009        } else if (strcmp(argv[i],"-size") == 0) {
    10091010            if (++i < argc) {
    10101011                size = atoi(argv[i]);
    1011             }
    1012         } else if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
    1013             return TCL_ERROR;
    1014         }
    1015     }
    1016     p->flags |= INVALIDATE_CACHE;       /* label */
     1012            }
     1013        } else if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
     1014            return TCL_ERROR;
     1015        }
     1016    }
     1017    p->flags |= INVALIDATE_CACHE; /* label */
    10171018    if (!defer || push) {
    1018         p->flags |= UPDATE_PENDING;
     1019        p->flags |= UPDATE_PENDING;
    10191020    }
    10201021    if (push) {
    1021         p->flags |= FORCE_UPDATE;
    1022     }
    1023     SendToPymol(p, "set label_color,white,%s\nset label_size,%d,%s\n", 
    1024             model, size, model);
     1022        p->flags |= FORCE_UPDATE;
     1023    }
     1024    SendToPymol(p, "set label_color,white,%s\nset label_size,%d,%s\n",
     1025            model, size, model);
    10251026    if (bool) {
    10261027        SendToPymol(p, "label %s,\"%%s%%s\" %% (ID,name)\n", model);
     
    10311032}
    10321033
    1033 /* 
     1034/*
    10341035 * LoadPDBCmd --
    10351036 *
    1036  *      Load a PDB into pymol.  We write the pdb data into a temporary file
    1037  *      and then let pymol read it and delete it.  There is no good way to
    1038  *      load PDB data into pymol without using a file.  The specially created
    1039  *      routine "loadandremovepdbfile" in pymol will remove the file after
    1040  *      loading it. 
    1041  *
     1037 * Load a PDB into pymol.  We write the pdb data into a temporary file
     1038 * and then let pymol read it and delete it.  There is no good way to
     1039 * load PDB data into pymol without using a file.  The specially created
     1040 * routine "loadandremovepdbfile" in pymol will remove the file after
     1041 * loading it.
    10421042 */
    10431043static int
    1044 LoadPDBCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1045            const char *argv[])
     1044LoadPDBCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1045           const char *argv[])
    10461046{
    10471047    PymolProxy *p = clientData;
     
    10551055
    10561056    if (p == NULL){
    1057         return TCL_ERROR;
     1057        return TCL_ERROR;
    10581058    }
    10591059    clear_error(p);
    10601060    defer = push = FALSE;
    10611061    for(i = j = 1; i < argc; i++) {
    1062         if (strcmp(argv[i],"-defer") == 0) {
    1063             defer = TRUE;
    1064         } else if (strcmp(argv[i],"-push") == 0) {
    1065             push = TRUE;
    1066         } else {
    1067             if (j < i) {
    1068                 argv[j] = argv[i];
    1069             }
    1070             j++;
    1071         }
     1062        if (strcmp(argv[i],"-defer") == 0) {
     1063            defer = TRUE;
     1064        } else if (strcmp(argv[i],"-push") == 0) {
     1065            push = TRUE;
     1066        } else {
     1067            if (j < i) {
     1068                argv[j] = argv[i];
     1069            }
     1070            j++;
     1071        }
    10721072    }
    10731073    argc = j;
    10741074    if (argc < 4) {
    1075         Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
    1076                         " <data>|follows <model> <state> ?<numBytes>?\"",
    1077                         (char *)NULL);
    1078         return TCL_ERROR;
     1075        Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
     1076                        " <data>|follows <model> <state> ?<numBytes>?\"",
     1077                        (char *)NULL);
     1078        return TCL_ERROR;
    10791079    }
    10801080    string = argv[1];
    10811081    name   = argv[2];
    10821082    if (Tcl_GetInt(interp, argv[3], &state) != TCL_OK) {
    1083         return TCL_ERROR;
     1083        return TCL_ERROR;
    10841084    }
    10851085    numBytes = 0;
    10861086    status = BUFFER_ERROR;
    10871087    if (strcmp(string, "follows") == 0) {
    1088         int n;
    1089 
    1090         if (argc != 5) {
    1091             Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
    1092                         " follows <model> <state> <numBytes>\"", (char *)NULL);
    1093             return TCL_ERROR;
    1094         }
    1095         if (Tcl_GetInt(interp, argv[4], &n) != TCL_OK) {
    1096             return TCL_ERROR;
    1097         }
    1098         if (n < 0) {
    1099             Tcl_AppendResult(interp, "bad value for # bytes \"", argv[4],
    1100                         "\"", (char *)NULL);
    1101             return TCL_ERROR;
    1102         }
    1103         numBytes = (size_t)n;
     1088        int n;
     1089
     1090        if (argc != 5) {
     1091            Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
     1092                        " follows <model> <state> <numBytes>\"", (char *)NULL);
     1093            return TCL_ERROR;
     1094        }
     1095        if (Tcl_GetInt(interp, argv[4], &n) != TCL_OK) {
     1096            return TCL_ERROR;
     1097        }
     1098        if (n < 0) {
     1099            Tcl_AppendResult(interp, "bad value for # bytes \"", argv[4],
     1100                        "\"", (char *)NULL);
     1101            return TCL_ERROR;
     1102        }
     1103        numBytes = (size_t)n;
    11041104    }
    11051105    if (!defer || push) {
    1106         p->flags |= UPDATE_PENDING;
     1106        p->flags |= UPDATE_PENDING;
    11071107    }
    11081108    if (push) {
    1109         p->flags |= FORCE_UPDATE;
     1109        p->flags |= FORCE_UPDATE;
    11101110    }
    11111111    p->cacheId = state;
     
    11161116    allocated = malloc(sizeof(char) * numBytes);
    11171117    if (allocated == NULL) {
    1118         Tcl_AppendResult(interp, "can't allocate buffer for pdbdata.",
    1119                         (char *)NULL);
    1120         return TCL_ERROR;
     1118        Tcl_AppendResult(interp, "can't allocate buffer for pdbdata.",
     1119                        (char *)NULL);
     1120        return TCL_ERROR;
    11211121    }
    11221122    status = ReadFollowingData(&p->client, allocated, numBytes);
    11231123    if (status != BUFFER_OK) {
    1124         Tcl_AppendResult(interp, "can't read pdbdata from client.",
    1125                         (char *)NULL);
    1126         free(allocated);
    1127         return TCL_ERROR;
     1124        Tcl_AppendResult(interp, "can't read pdbdata from client.",
     1125                        (char *)NULL);
     1126        free(allocated);
     1127        return TCL_ERROR;
    11281128    }
    11291129    string = (const char *)allocated;
    11301130    {
    1131         int f;
    1132         ssize_t numWritten;
    1133         char fileName[200];
    1134 
    1135         strcpy(fileName, "/tmp/pdb.XXXXXX");
    1136         p->status = TCL_ERROR;
    1137         f = mkstemp(fileName);
    1138         if (f < 0) {
    1139             Tcl_AppendResult(interp, "can't create temporary file \"",
    1140                 fileName, "\":", Tcl_PosixError(interp), (char *)NULL);
    1141             goto error;
    1142         }
    1143         numWritten = write(f, string, numBytes);
    1144         if (numBytes != numWritten) {
    1145             Tcl_AppendResult(interp, "can't write PDB data to \"",
    1146                 fileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
    1147             close(f);
    1148             goto error;
    1149         }
    1150         close(f);
    1151         SendToPymol(p, "loadandremovepdbfile %s,%s,%d\n", fileName, name,
    1152                     state);
    1153         p->status = TCL_OK;
     1131        int f;
     1132        ssize_t numWritten;
     1133        char fileName[200];
     1134
     1135        strcpy(fileName, "/tmp/pdb.XXXXXX");
     1136        p->status = TCL_ERROR;
     1137        f = mkstemp(fileName);
     1138        if (f < 0) {
     1139            Tcl_AppendResult(interp, "can't create temporary file \"",
     1140                fileName, "\":", Tcl_PosixError(interp), (char *)NULL);
     1141            goto error;
     1142        }
     1143        numWritten = write(f, string, numBytes);
     1144        if (numBytes != numWritten) {
     1145            Tcl_AppendResult(interp, "can't write PDB data to \"",
     1146                fileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
     1147            close(f);
     1148            goto error;
     1149        }
     1150        close(f);
     1151        SendToPymol(p, "loadandremovepdbfile %s,%s,%d\n", fileName, name,
     1152                    state);
     1153        p->status = TCL_OK;
    11541154    }
    11551155 error:
    11561156    if (allocated != NULL) {
    1157         free(allocated);
     1157        free(allocated);
    11581158    }
    11591159    return p->status;
     
    11611161
    11621162static int
    1163 OrthoscopicCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1164               const char *argv[])
     1163OrthoscopicCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1164              const char *argv[])
    11651165{
    11661166    PymolProxy *p = clientData;
     
    11731173        if (strcmp(argv[i],"-defer") == 0) {
    11741174            defer = TRUE;
    1175         } else if (strcmp(argv[i],"-push") == 0) {
     1175        } else if (strcmp(argv[i],"-push") == 0) {
    11761176            push = TRUE;
    1177         } else {
    1178             if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
    1179                 return TCL_ERROR;
    1180             }
    1181         }
     1177        } else {
     1178            if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
     1179                return TCL_ERROR;
     1180            }
     1181        }
    11821182    }
    11831183    p->flags |= INVALIDATE_CACHE; /* orthoscopic */
    11841184    if (!defer || push) {
    1185         p->flags |= UPDATE_PENDING;
     1185        p->flags |= UPDATE_PENDING;
    11861186    }
    11871187    if (push) {
    1188         p->flags |= FORCE_UPDATE;
     1188        p->flags |= FORCE_UPDATE;
    11891189    }
    11901190    SendToPymol(p, "set orthoscopic=%d\n", bool);
     
    11921192}
    11931193
    1194 /* 
     1194/*
    11951195 * PanCmd --
    11961196 *
    1197  *      Issue "move" commands for changes in the x and y coordinates of the
    1198  *      camera.  The problem here is that there is no event compression.
    1199  *      Consecutive "pan" commands are not compressed into a single
    1200  *      directive.  The means that the pymol server will render scenes that
    1201  *      are not used by the client.
     1197 * Issue "move" commands for changes in the x and y coordinates of the
     1198 * camera.  The problem here is that there is no event compression.
     1199 * Consecutive "pan" commands are not compressed into a single
     1200 * directive.  The means that the pymol server will render scenes that
     1201 * are not used by the client.
    12021202 *
    1203  *      Need to 1) defer the "move" commands until we find the next command
    1204  *      isn't a "pan". 2) Track the x and y coordinates as they are
    1205  *      compressed.
     1203 * Need to 1) defer the "move" commands until we find the next command
     1204 * isn't a "pan". 2) Track the x and y coordinates as they are
     1205 * compressed.
    12061206 */
    12071207static int
     
    12161216    defer = push = FALSE;
    12171217    for (i = 1; i < argc; i++) {
    1218         if (strcmp(argv[i],"-defer") == 0) {
    1219             defer = 1;
    1220         } else if (strcmp(argv[i],"-push") == 0) {
    1221             push = 1;
    1222         } else {
    1223             break;
    1224         }
     1218        if (strcmp(argv[i],"-defer") == 0) {
     1219            defer = 1;
     1220        } else if (strcmp(argv[i],"-push") == 0) {
     1221            push = 1;
     1222        } else {
     1223            break;
     1224        }
    12251225    }
    12261226    if ((Tcl_GetDouble(interp, argv[i], &x) != TCL_OK) ||
    1227         (Tcl_GetDouble(interp, argv[i+1], &y) != TCL_OK)) {
    1228         return TCL_ERROR;
    1229     }
    1230     p->flags |= INVALIDATE_CACHE;       /* pan */
     1227        (Tcl_GetDouble(interp, argv[i+1], &y) != TCL_OK)) {
     1228        return TCL_ERROR;
     1229    }
     1230    p->flags |= INVALIDATE_CACHE; /* pan */
    12311231    if (!defer || push) {
    1232         p->flags |= UPDATE_PENDING;
     1232        p->flags |= UPDATE_PENDING;
    12331233    }
    12341234    if (push) {
    1235         p->flags |= FORCE_UPDATE;
     1235        p->flags |= FORCE_UPDATE;
    12361236    }
    12371237    if ((x != 0.0f) || (y != 0.0f)) {
    1238         p->xPan = x * 0.05;
    1239         p->yPan = -y * 0.05;
    1240         p->flags |= PAN_PENDING;
     1238        p->xPan = x * 0.05;
     1239        p->yPan = -y * 0.05;
     1240        p->flags |= PAN_PENDING;
    12411241    }
    12421242    return p->status;
     
    12801280     * The extra information is contained in the token we get from the
    12811281     * molvisviewer client, the frame number, and rock offset. */
    1282     SendToPymol(p, "png -:%d:%d:%d,format=1\n", p->cacheId, p->frame, 
    1283             p->rockOffset);
     1282    SendToPymol(p, "png -:%d:%d:%d,format=1\n", p->cacheId, p->frame,
     1283            p->rockOffset);
    12841284    p->flags &= ~(UPDATE_PENDING|FORCE_UPDATE);
    12851285    return p->status;
     
    12881288
    12891289static int
    1290 PrintCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1291         const char *argv[])
     1290PrintCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1291        const char *argv[])
    12921292{
    12931293    PymolProxy *p = clientData;
     
    12981298
    12991299    if (argc != 5) {
    1300         Tcl_AppendResult(interp, "wrong # arguments: should be \"",
    1301                         argv[0], " token width height color\"", (char *)NULL);
    1302         return TCL_ERROR;
     1300        Tcl_AppendResult(interp, "wrong # arguments: should be \"",
     1301                        argv[0], " token width height color\"", (char *)NULL);
     1302        return TCL_ERROR;
    13031303    }
    13041304    token = argv[1];
    13051305    if (Tcl_GetInt(interp, argv[2], &width) != TCL_OK) {
    1306         return TCL_ERROR;
     1306        return TCL_ERROR;
    13071307    }
    13081308    if (Tcl_GetInt(interp, argv[3], &height) != TCL_OK) {
    1309         return TCL_ERROR;
     1309        return TCL_ERROR;
    13101310    }
    13111311    bgcolor = argv[4];
    13121312    /* Force pymol to update the current scene. */
    13131313    if (strcmp(bgcolor, "none") == 0) {
    1314         SendToPymol(p, "set ray_opaque_background,off\n");
    1315         SendToPymol(p, "refresh\n", bgcolor);
     1314        SendToPymol(p, "set ray_opaque_background,off\n");
     1315        SendToPymol(p, "refresh\n", bgcolor);
    13161316    } else {
    1317         SendToPymol(p, "set ray_opaque_background,on\n");
    1318         SendToPymol(p, "bg_color %s\nrefresh\n", bgcolor);
     1317        SendToPymol(p, "set ray_opaque_background,on\n");
     1318        SendToPymol(p, "bg_color %s\nrefresh\n", bgcolor);
    13191319    }
    13201320    /* This is a hack. We're encoding the filename to pass extra information
    13211321     * to the MyPNGWrite routine inside of pymol. Ideally these would be
    13221322     * parameters of a new "molvispng" command that would be passed all the
    1323      * way through to MyPNGWrite. 
     1323     * way through to MyPNGWrite.
    13241324     *
    13251325     * The extra information is contained in the token we get from the
    13261326     * molvisviewer client, the frame number, and rock offset.
    13271327     */
    1328     SendToPymol(p, "png -:%s:0:0,width=%d,height=%d,ray=1,dpi=300\n", 
    1329             token, width, height);
     1328    SendToPymol(p, "png -:%s:0:0,width=%d,height=%d,ray=1,dpi=300\n",
     1329            token, width, height);
    13301330    SendToPymol(p, "bg_color black\n");
    13311331    return p->status;
     
    13541354    p->flags |= INVALIDATE_CACHE; /* raw */
    13551355    if (!defer || push) {
    1356         p->flags |= UPDATE_PENDING;
     1356        p->flags |= UPDATE_PENDING;
    13571357    }
    13581358    if (push) {
    1359         p->flags |= FORCE_UPDATE;
     1359        p->flags |= FORCE_UPDATE;
    13601360    }
    13611361    SendToPymol(p,"%s\n", cmd);
     
    13641364
    13651365static int
    1366 ResetCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1367         const char *argv[])
     1366ResetCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1367        const char *argv[])
    13681368{
    13691369    PymolProxy *p = clientData;
     
    13781378            push = 1;
    13791379    }
    1380                
     1380
    13811381    p->flags |= INVALIDATE_CACHE; /* reset */
    13821382    if (!defer || push) {
    1383         p->flags |= UPDATE_PENDING;
     1383        p->flags |= UPDATE_PENDING;
    13841384    }
    13851385    if (push) {
    1386         p->flags |= FORCE_UPDATE;
     1386        p->flags |= FORCE_UPDATE;
    13871387    }
    13881388    SendToPymol(p, "reset\nzoom complete=1\n");
     
    13911391
    13921392static int
    1393 RockCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1394         const char *argv[])
     1393RockCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1394        const char *argv[])
    13951395{
    13961396    PymolProxy *p = clientData;
     
    14091409            y = atof( argv[arg] );
    14101410    }
    1411                
     1411
    14121412    /* Does not invalidate cache. */
    14131413
    14141414    if (!defer || push) {
    1415         p->flags |= UPDATE_PENDING;
     1415        p->flags |= UPDATE_PENDING;
    14161416    }
    14171417    if (push) {
    1418         p->flags |= FORCE_UPDATE;
     1418        p->flags |= FORCE_UPDATE;
    14191419    }
    14201420    SendToPymol(p,"turn y, %f\n", y - p->rockOffset);
     
    14241424
    14251425static int
    1426 RepresentationCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1427                   const char *argv[])
     1426RepresentationCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1427                  const char *argv[])
    14281428{
    14291429    PymolProxy *p = clientData;
     
    14391439        if (strcmp(argv[i],"-defer") == 0 ) {
    14401440            defer = TRUE;
    1441         } else if (strcmp(argv[i],"-push") == 0) {
     1441        } else if (strcmp(argv[i],"-push") == 0) {
    14421442            push = TRUE;
    1443         } else if (strcmp(argv[i],"-model") == 0) {
     1443        } else if (strcmp(argv[i],"-model") == 0) {
    14441444            if (++i < argc) {
    14451445                model = argv[i];
    1446             }
     1446            }
    14471447        } else {
    14481448            rep = argv[i];
    1449         }
     1449        }
    14501450    }
    14511451    if (rep == NULL) {
    1452         Tcl_AppendResult(interp, "missing representation argument",
    1453                         (char *)NULL);
    1454         return TCL_ERROR;
     1452        Tcl_AppendResult(interp, "missing representation argument",
     1453                        (char *)NULL);
     1454        return TCL_ERROR;
    14551455    }
    14561456
    14571457    p->flags |= INVALIDATE_CACHE; /* representation */
    14581458    if (!defer || push) {
    1459         p->flags |= UPDATE_PENDING;
     1459        p->flags |= UPDATE_PENDING;
    14601460    }
    14611461    if (push) {
    1462         p->flags |= FORCE_UPDATE;
     1462        p->flags |= FORCE_UPDATE;
    14631463    }
    14641464    if (strcmp(rep, "ballnstick") == 0) { /* Ball 'n Stick */
    1465         SendToPymol(p,
    1466               "set stick_color,white,%s\n"
    1467               "show sticks,%s\n"
    1468               "show spheres,%s\n"
    1469               "hide lines,%s\n"
    1470               "hide cartoon,%s\n",
    1471               model, model, model, model, model);
    1472     } else if (strcmp(rep, "spheres") == 0) { /* spheres */   
    1473         SendToPymol(p,
    1474               "hide sticks,%s\n"
    1475               "show spheres,%s\n"
    1476               "hide lines,%s\n"
    1477               "hide cartoon,%s\n"
    1478               "set sphere_quality,2,%s\n"
    1479               "set ambient,.2,%s\n",
    1480               model, model, model, model, model, model);
    1481     } else if (strcmp(rep, "none") == 0) { /* nothing */   
    1482         SendToPymol(p,
    1483               "hide sticks,%s\n",
    1484               "hide spheres,%s\n"
    1485               "hide lines,%s\n"
    1486               "hide cartoon,%s\n",
    1487               model, model, model, model);
    1488     } else if (strcmp(rep, "sticks") == 0) { /* sticks */   
    1489         SendToPymol(p,
    1490               "set stick_color,white,%s\n"
    1491               "show sticks,%s\n"
    1492               "hide spheres,%s\n"
    1493               "hide lines,%s\n"
    1494               "hide cartoon,%s\n",
    1495               model, model, model, model, model);
    1496     } else if (strcmp(rep, "lines") == 0) { /* lines */   
    1497         SendToPymol(p,
    1498               "hide sticks,%s\n"
    1499               "hide spheres,%s\n"
    1500               "show lines,%s\n"
    1501               "hide cartoon,%s\n",
    1502               model, model, model, model);
    1503     } else if (strcmp(rep, "cartoon") == 0) { /* cartoon */   
    1504         SendToPymol(p,
    1505               "hide sticks,%s\n"
    1506               "hide spheres,%s\n"
    1507               "hide lines,%s\n"
    1508               "show cartoon,%s\n",
    1509               model, model, model, model);
    1510     } 
     1465        SendToPymol(p,
     1466              "set stick_color,white,%s\n"
     1467              "show sticks,%s\n"
     1468              "show spheres,%s\n"
     1469              "hide lines,%s\n"
     1470              "hide cartoon,%s\n",
     1471              model, model, model, model, model);
     1472    } else if (strcmp(rep, "spheres") == 0) { /* spheres */
     1473        SendToPymol(p,
     1474              "hide sticks,%s\n"
     1475              "show spheres,%s\n"
     1476              "hide lines,%s\n"
     1477              "hide cartoon,%s\n"
     1478              "set sphere_quality,2,%s\n"
     1479              "set ambient,.2,%s\n",
     1480              model, model, model, model, model, model);
     1481    } else if (strcmp(rep, "none") == 0) { /* nothing */
     1482        SendToPymol(p,
     1483              "hide sticks,%s\n",
     1484              "hide spheres,%s\n"
     1485              "hide lines,%s\n"
     1486              "hide cartoon,%s\n",
     1487              model, model, model, model);
     1488    } else if (strcmp(rep, "sticks") == 0) { /* sticks */
     1489        SendToPymol(p,
     1490              "set stick_color,white,%s\n"
     1491              "show sticks,%s\n"
     1492              "hide spheres,%s\n"
     1493              "hide lines,%s\n"
     1494              "hide cartoon,%s\n",
     1495              model, model, model, model, model);
     1496    } else if (strcmp(rep, "lines") == 0) { /* lines */
     1497        SendToPymol(p,
     1498              "hide sticks,%s\n"
     1499              "hide spheres,%s\n"
     1500              "show lines,%s\n"
     1501              "hide cartoon,%s\n",
     1502              model, model, model, model);
     1503    } else if (strcmp(rep, "cartoon") == 0) { /* cartoon */
     1504        SendToPymol(p,
     1505              "hide sticks,%s\n"
     1506              "hide spheres,%s\n"
     1507              "hide lines,%s\n"
     1508              "show cartoon,%s\n",
     1509              model, model, model, model);
     1510    }
    15111511    return p->status;
    15121512}
    15131513
    1514 /* 
     1514/*
    15151515 * RotateCmd --
    15161516 *
    1517  *      Issue "turn" commands for changes in the angle of the camera.  The
    1518  *      problem here is that there is no event compression.  Consecutive
    1519  *      "rotate" commands are not compressed into a single directive.  The
    1520  *      means that the pymol server will render many scene that are not used
    1521  *      by the client.
     1517 * Issue "turn" commands for changes in the angle of the camera.  The
     1518 * problem here is that there is no event compression.  Consecutive
     1519 * "rotate" commands are not compressed into a single directive.  The
     1520 * means that the pymol server will render many scene that are not used
     1521 * by the client.
    15221522 *
    1523  *      Need to 1) defer the "turn" commands until we find the next command
    1524  *      isn't a "rotate". 2) Track the rotation angles as they are compressed.
     1523 * Need to 1) defer the "turn" commands until we find the next command
     1524 * isn't a "rotate". 2) Track the rotation angles as they are compressed.
    15251525 */
    15261526static int
    1527 RotateCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1528           const char *argv[])
     1527RotateCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1528          const char *argv[])
    15291529{
    15301530    PymolProxy *p = clientData;
     
    15361536    xAngle = yAngle = zAngle = 0.0f;
    15371537    for(arg = 1; arg < argc; arg++) {
    1538         if (strcmp(argv[arg],"-defer") == 0) {
    1539             defer = 1;
    1540         } else if (strcmp(argv[arg],"-push") == 0) {
    1541             push = 1;
    1542         } else  if (varg == 1) {
    1543             double value;
    1544             if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
    1545                 return TCL_ERROR;
    1546             }
    1547             xAngle = (float)value;
    1548             varg++;
    1549         } else if (varg == 2) {
    1550             double value;
    1551             if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
    1552                 return TCL_ERROR;
    1553             }
    1554             yAngle = (float)value;
    1555             varg++;
    1556         } else if (varg == 3) {
    1557             double value;
    1558             if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
    1559                 return TCL_ERROR;
    1560             }
    1561             zAngle = (float)value;
    1562             varg++;
    1563         }
    1564     } 
     1538        if (strcmp(argv[arg],"-defer") == 0) {
     1539            defer = 1;
     1540        } else if (strcmp(argv[arg],"-push") == 0) {
     1541            push = 1;
     1542        } else  if (varg == 1) {
     1543            double value;
     1544            if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
     1545                return TCL_ERROR;
     1546            }
     1547            xAngle = (float)value;
     1548            varg++;
     1549        } else if (varg == 2) {
     1550            double value;
     1551            if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
     1552                return TCL_ERROR;
     1553            }
     1554            yAngle = (float)value;
     1555            varg++;
     1556        } else if (varg == 3) {
     1557            double value;
     1558            if (Tcl_GetDouble(interp, argv[arg], &value) != TCL_OK) {
     1559                return TCL_ERROR;
     1560            }
     1561            zAngle = (float)value;
     1562            varg++;
     1563        }
     1564    }
    15651565    p->flags |= INVALIDATE_CACHE; /* rotate */
    15661566    if (!defer || push) {
    1567         p->flags |= UPDATE_PENDING;
     1567        p->flags |= UPDATE_PENDING;
    15681568    }
    15691569    if (push) {
    1570         p->flags |= FORCE_UPDATE;
     1570        p->flags |= FORCE_UPDATE;
    15711571    }
    15721572    if ((xAngle != 0.0f) || (yAngle != 0.0f) || (zAngle != 0.0f)) {
    1573         p->xAngle += xAngle;
    1574         p->yAngle += yAngle;
    1575         p->zAngle += zAngle;
    1576         p->flags |= ROTATE_PENDING;
     1573        p->xAngle += xAngle;
     1574        p->yAngle += yAngle;
     1575        p->zAngle += zAngle;
     1576        p->flags |= ROTATE_PENDING;
    15771577    }
    15781578    return p->status;
     
    15801580
    15811581static int
    1582 ScreenCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1583           const char *argv[])
     1582ScreenCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1583          const char *argv[])
    15841584{
    15851585    PymolProxy *p = clientData;
     
    15911591    varg = 1;
    15921592    for(i = 1; i < argc; i++) {
    1593         if ( strcmp(argv[i],"-defer") == 0 ) 
     1593        if ( strcmp(argv[i],"-defer") == 0 )
    15941594            defer = 1;
    15951595        else if ( strcmp(argv[i], "-push") == 0 )
     
    16061606    }
    16071607    if ((width < 0) || (height < 0)) {
    1608         return TCL_ERROR;
     1608        return TCL_ERROR;
    16091609    }
    16101610    p->flags |= INVALIDATE_CACHE; /* viewport */
    16111611    if (!defer || push) {
    1612         p->flags |= UPDATE_PENDING;
     1612        p->flags |= UPDATE_PENDING;
    16131613    }
    16141614    if (push) {
    1615         p->flags |= FORCE_UPDATE;
     1615        p->flags |= FORCE_UPDATE;
    16161616    }
    16171617    p->width = width;
     
    16221622
    16231623static int
    1624 SphereScaleCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1625            const char *argv[])
     1624SphereScaleCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1625           const char *argv[])
    16261626{
    16271627    int defer = 0, push = 0, i;
     
    16351635        if ( strcmp(argv[i],"-defer") == 0 ) {
    16361636            defer = 1;
    1637         } else if (strcmp(argv[i],"-push") == 0) {
     1637        } else if (strcmp(argv[i],"-push") == 0) {
    16381638            push = 1;
    1639         } else if (strcmp(argv[i],"-model") == 0) {
     1639        } else if (strcmp(argv[i],"-model") == 0) {
    16401640            if (++i < argc) {
    16411641                model = argv[i];
    1642             }
     1642            }
    16431643        } else {
    1644             if (Tcl_GetDouble(interp, argv[i], &scale) != TCL_OK) {
    1645                 return TCL_ERROR;
    1646             }
    1647         }
     1644            if (Tcl_GetDouble(interp, argv[i], &scale) != TCL_OK) {
     1645                return TCL_ERROR;
     1646            }
     1647        }
    16481648    }
    16491649    p->flags |= INVALIDATE_CACHE;  /* sphere_scale */
    16501650    if (!defer || push) {
    1651         p->flags |= UPDATE_PENDING;
     1651        p->flags |= UPDATE_PENDING;
    16521652    }
    16531653    if (push) {
    1654         p->flags |= FORCE_UPDATE;
     1654        p->flags |= FORCE_UPDATE;
    16551655    }
    16561656    if (strcmp(model, "all") == 0) {
    1657         p->flags |= ATOM_SCALE_PENDING;
    1658         p->sphereScale = scale;
     1657        p->flags |= ATOM_SCALE_PENDING;
     1658        p->sphereScale = scale;
    16591659    } else {
    1660         SendToPymol(p, "set sphere_scale,%f,%s\n", scale, model);
     1660        SendToPymol(p, "set sphere_scale,%f,%s\n", scale, model);
    16611661    }
    16621662    return p->status;
     
    16641664
    16651665static int
    1666 StickRadiusCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1667                const char *argv[])
     1666StickRadiusCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1667               const char *argv[])
    16681668{
    16691669    PymolProxy *p = clientData;
     
    16771677        if (strcmp(argv[i],"-defer") == 0 ) {
    16781678            defer = 1;
    1679         } else if (strcmp(argv[i],"-push") == 0) {
     1679        } else if (strcmp(argv[i],"-push") == 0) {
    16801680            push = 1;
    1681         } else if (strcmp(argv[i],"-model") == 0) {
     1681        } else if (strcmp(argv[i],"-model") == 0) {
    16821682            if (++i < argc)
    16831683                model = argv[i];
    16841684        } else {
    1685             if (Tcl_GetDouble(interp, argv[i], &scale) != TCL_OK) {
    1686                 return TCL_ERROR;
    1687             }
    1688         }
     1685            if (Tcl_GetDouble(interp, argv[i], &scale) != TCL_OK) {
     1686                return TCL_ERROR;
     1687            }
     1688        }
    16891689    }
    16901690    p->flags |= INVALIDATE_CACHE;  /* stick_radius */
    16911691    if (!defer || push) {
    1692         p->flags |= UPDATE_PENDING;
     1692        p->flags |= UPDATE_PENDING;
    16931693    }
    16941694    if (push) {
    1695         p->flags |= FORCE_UPDATE;
     1695        p->flags |= FORCE_UPDATE;
    16961696    }
    16971697
    16981698    if (strcmp(model, "all") == 0) {
    1699         p->flags |= STICK_RADIUS_PENDING;
    1700         p->stickRadius = scale;
     1699        p->flags |= STICK_RADIUS_PENDING;
     1700        p->stickRadius = scale;
    17011701    } else {
    1702         SendToPymol(p, "set stick_radius,%f,%s\n", scale, model);
     1702        SendToPymol(p, "set stick_radius,%f,%s\n", scale, model);
    17031703    }
    17041704    return p->status;
     
    17061706
    17071707static int
    1708 TransparencyCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1709                 const char *argv[])
     1708TransparencyCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1709                const char *argv[])
    17101710{
    17111711    PymolProxy *p = clientData;
     
    17221722        if ( strcmp(argv[i],"-defer") == 0 ) {
    17231723            defer = 1;
    1724         } else if (strcmp(argv[i],"-push") == 0) {
     1724        } else if (strcmp(argv[i],"-push") == 0) {
    17251725            push = 1;
    1726         } else if (strcmp(argv[i],"-model") == 0) {
     1726        } else if (strcmp(argv[i],"-model") == 0) {
    17271727            if (++i < argc) {
    17281728                model = argv[i];
    1729             }
    1730         } else {
    1731             transparency = atof(argv[i]);
    1732         }
     1729            }
     1730        } else {
     1731            transparency = atof(argv[i]);
     1732        }
    17331733    }
    17341734    p->flags |= INVALIDATE_CACHE; /* transparency */
    17351735    if (!defer || push) {
    1736         p->flags |= UPDATE_PENDING;
     1736        p->flags |= UPDATE_PENDING;
    17371737    }
    17381738    if (push) {
    1739         p->flags |= FORCE_UPDATE;
    1740     } 
    1741     SendToPymol(p, 
    1742           "set sphere_transparency,%g,%s\n"
    1743           "set stick_transparency,%g,%s\n"
    1744           "set cartoon_transparency,%g,%s\n",
    1745           transparency, model, transparency, model,
    1746           transparency, model);
     1739        p->flags |= FORCE_UPDATE;
     1740    }
     1741    SendToPymol(p,
     1742          "set sphere_transparency,%g,%s\n"
     1743          "set stick_transparency,%g,%s\n"
     1744          "set cartoon_transparency,%g,%s\n",
     1745          transparency, model, transparency, model,
     1746          transparency, model);
    17471747    return p->status;
    17481748}
    17491749
    17501750static int
    1751 VMouseCmd(ClientData clientData, Tcl_Interp *interp, int argc, 
    1752           const char *argv[])
     1751VMouseCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1752          const char *argv[])
    17531753{
    17541754    PymolProxy *p = clientData;
     
    17811781    }
    17821782
    1783     p->flags |= INVALIDATE_CACHE;       /* vmouse */
     1783    p->flags |= INVALIDATE_CACHE; /* vmouse */
    17841784    if (!defer || push) {
    1785         p->flags |= UPDATE_PENDING;
     1785        p->flags |= UPDATE_PENDING;
    17861786    }
    17871787    if (push) {
    1788         p->flags |= FORCE_UPDATE;
     1788        p->flags |= FORCE_UPDATE;
    17891789    }
    17901790    SendToPymol(p, "vmouse %d,%d,%d,%d,%d\n", arg1, arg2, arg3, arg4, arg5);
     
    17931793
    17941794
    1795 /* 
     1795/*
    17961796 * ZoomCmd --
    17971797 *
    1798  *      Issue "move" commands for changes in the z-coordinate of the camera.
    1799  *      The problem here is that there is no event compression.  Consecutive
    1800  *      "zoom" commands are not compressed into a single directive.  The means
    1801  *      that the pymol server will render scenes that are not used by the
    1802  *      client.
     1798 * Issue "move" commands for changes in the z-coordinate of the camera.
     1799 * The problem here is that there is no event compression.  Consecutive
     1800 * "zoom" commands are not compressed into a single directive.  The means
     1801 * that the pymol server will render scenes that are not used by the
     1802 * client.
    18031803 *
    1804  *      Need to 1) defer the "move" commands until we find the next command
    1805  *      isn't a "zoom". 2) Track the z-coordinate as they are compressed.
     1804 * Need to 1) defer the "move" commands until we find the next command
     1805 * isn't a "zoom". 2) Track the z-coordinate as they are compressed.
    18061806 */
    18071807static int
     
    18151815
    18161816    for(i = 1; i < argc; i++) {
    1817         if (strcmp(argv[i],"-defer") == 0)
    1818             defer = 1;
    1819         else if (strcmp(argv[i],"-push") == 0)
    1820             push = 1;
    1821         else if (varg == 1) {
    1822             double value;
    1823             if (Tcl_GetDouble(interp, argv[i], &value) != TCL_OK) {
    1824                 return TCL_ERROR;
    1825             }
    1826             factor = (float)value;
    1827             varg++;
    1828         }
     1817        if (strcmp(argv[i],"-defer") == 0)
     1818            defer = 1;
     1819        else if (strcmp(argv[i],"-push") == 0)
     1820            push = 1;
     1821        else if (varg == 1) {
     1822            double value;
     1823            if (Tcl_GetDouble(interp, argv[i], &value) != TCL_OK) {
     1824                return TCL_ERROR;
     1825            }
     1826            factor = (float)value;
     1827            varg++;
     1828        }
    18291829    }
    18301830    p->flags |= INVALIDATE_CACHE; /* Zoom */
    18311831    if (!defer || push) {
    1832         p->flags |= UPDATE_PENDING;
     1832        p->flags |= UPDATE_PENDING;
    18331833    }
    18341834    if (push) {
    1835         p->flags |= FORCE_UPDATE;
     1835        p->flags |= FORCE_UPDATE;
    18361836    }
    18371837    if (factor != 0.0) {
    1838         p->zoom = factor;
    1839         p->flags |= ZOOM_PENDING;
     1838        p->zoom = factor;
     1839        p->flags |= ZOOM_PENDING;
    18401840    }
    18411841    return p->status;
    18421842}
    18431843
    1844        
    1845 
    1846 static int
    1847 ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr) 
     1844
     1845
     1846static int
     1847ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr)
    18481848{
    18491849    struct timeval tv;
     
    18601860    if (result != TCL_OK) {
    18611861#if EXEC_DEBUG
    1862         DEBUG("result was %s\n", Tcl_GetString(Tcl_GetObjResult(interp)));
     1862        DEBUG("result was %s\n", Tcl_GetString(Tcl_GetObjResult(interp)));
    18631863#endif
    18641864    }
     
    18761876{
    18771877    if (p->flags & VIEWPORT_PENDING) {
    1878         SendToPymol(p, "viewport %d,%d\n", p->width, p->height);
    1879         SendToPymol(p, "refresh\n");
    1880         p->flags &= ~VIEWPORT_PENDING;
     1878        SendToPymol(p, "viewport %d,%d\n", p->width, p->height);
     1879        SendToPymol(p, "refresh\n");
     1880        p->flags &= ~VIEWPORT_PENDING;
    18811881    }
    18821882}
     
    18871887    if (p->flags & ZOOM_PENDING) {
    18881888        SendToPymol(p, "move z,%f\n", p->zoom);
    1889         p->flags &= ~ZOOM_PENDING;
     1889        p->flags &= ~ZOOM_PENDING;
    18901890    }
    18911891}
     
    18951895{
    18961896    if (p->flags & PAN_PENDING) {
    1897         SendToPymol(p, "move x,%f\nmove y,%f\n", p->xPan, p->yPan);
    1898         p->flags &= ~PAN_PENDING;
     1897        SendToPymol(p, "move x,%f\nmove y,%f\n", p->xPan, p->yPan);
     1898        p->flags &= ~PAN_PENDING;
    18991899    }
    19001900}
     
    19041904{
    19051905    if (p->flags & ROTATE_PENDING) {
    1906         /* Every pymol command line generates a new rendering. Execute all
    1907         * three turns as a single command line. */
    1908         SendToPymol(p,"turn x,%f\nturn y,%f\nturn z,%f\n", p->xAngle, p->yAngle,
    1909                 p->zAngle);
    1910         p->xAngle = p->yAngle = p->zAngle = 0.0f;
    1911         p->flags &= ~ROTATE_PENDING;
     1906        /* Every pymol command line generates a new rendering. Execute all
     1907        * three turns as a single command line. */
     1908        SendToPymol(p,"turn x,%f\nturn y,%f\nturn z,%f\n", p->xAngle, p->yAngle,
     1909                p->zAngle);
     1910        p->xAngle = p->yAngle = p->zAngle = 0.0f;
     1911        p->flags &= ~ROTATE_PENDING;
    19121912    }
    19131913}
     
    19171917{
    19181918    if (p->flags & ATOM_SCALE_PENDING) {
    1919         SendToPymol(p, "set sphere_scale,%f,all\n", p->sphereScale);
    1920         p->flags &= ~ATOM_SCALE_PENDING;
     1919        SendToPymol(p, "set sphere_scale,%f,all\n", p->sphereScale);
     1920        p->flags &= ~ATOM_SCALE_PENDING;
    19211921    }
    19221922}
     
    19261926{
    19271927    if (p->flags & STICK_RADIUS_PENDING) {
    1928         SendToPymol(p, "set stick_radius,%f,all\n", p->stickRadius);
    1929         p->flags &= ~STICK_RADIUS_PENDING;
     1928        SendToPymol(p, "set stick_radius,%f,all\n", p->stickRadius);
     1929        p->flags &= ~STICK_RADIUS_PENDING;
    19301930    }
    19311931}
     
    19361936    /* Handle all the pending setting changes now. */
    19371937    if (p->flags & VIEWPORT_PENDING) {
    1938         SetViewport(p);
     1938        SetViewport(p);
    19391939    }
    19401940    if (p->flags & ROTATE_PENDING) {
    1941         SetRotation(p);
     1941        SetRotation(p);
    19421942    }
    19431943    if (p->flags & PAN_PENDING) {
    1944         SetPan(p);
     1944        SetPan(p);
    19451945    }
    19461946    if (p->flags & ZOOM_PENDING) {
    1947         SetZoom(p);
     1947        SetZoom(p);
    19481948    }
    19491949    if (p->flags & ATOM_SCALE_PENDING) {
    1950         SetSphereScale(p);
     1950        SetSphereScale(p);
    19511951    }
    19521952    if (p->flags & STICK_RADIUS_PENDING) {
    1953         SetStickRadius(p);
     1953        SetStickRadius(p);
    19541954    }
    19551955}
     
    19631963    imgPtr = malloc(sizeof(Image) + dataLength);
    19641964    if (imgPtr == NULL) {
    1965         ERROR("can't allocate image of %lu bytes",
    1966               (unsigned long)(sizeof(Image) + dataLength));
    1967         abort();
     1965        ERROR("can't allocate image of %lu bytes",
     1966              (unsigned long)(sizeof(Image) + dataLength));
     1967        abort();
    19681968    }
    19691969    imgPtr->prevPtr = imgPtr->nextPtr = NULL;
     
    19741974#endif
    19751975    if (listPtr->headPtr != NULL) {
    1976         listPtr->headPtr->prevPtr = imgPtr;
     1976        listPtr->headPtr->prevPtr = imgPtr;
    19771977    }
    19781978    imgPtr->nextPtr = listPtr->headPtr;
    19791979    if (listPtr->tailPtr == NULL) {
    1980         listPtr->tailPtr = imgPtr;
     1980        listPtr->tailPtr = imgPtr;
    19811981    }
    19821982    listPtr->headPtr = imgPtr;
     
    19961996WriteImages(ImageList *listPtr, int fd)
    19971997{
    1998     Image *imgPtr, *prevPtr; 
     1998    Image *imgPtr, *prevPtr;
    19991999
    20002000    if (listPtr->tailPtr == NULL) {
    2001         ERROR("Should not be here: no image available to write");
    2002         return;
     2001        ERROR("Should not be here: no image available to write");
     2002        return;
    20032003    }
    20042004#if WRITE_DEBUG
    2005         DEBUG("Entering WriteImages");
     2005        DEBUG("Entering WriteImages");
    20062006#endif
    20072007    for (imgPtr = listPtr->tailPtr; imgPtr != NULL; imgPtr = prevPtr) {
    2008         ssize_t bytesLeft;
    2009 
    2010         assert(imgPtr->nextPtr == NULL);
    2011         prevPtr = imgPtr->prevPtr;
     2008        ssize_t bytesLeft;
     2009
     2010        assert(imgPtr->nextPtr == NULL);
     2011        prevPtr = imgPtr->prevPtr;
    20122012#if WRITE_DEBUG
    2013         DEBUG("WriteImages: image %d of %d bytes.", imgPtr->id,
    2014               imgPtr->bytesLeft);
    2015 #endif
    2016         for (bytesLeft = imgPtr->bytesLeft; bytesLeft > 0; /*empty*/) {
    2017             ssize_t numWritten;
     2013        DEBUG("WriteImages: image %d of %d bytes.", imgPtr->id,
     2014              imgPtr->bytesLeft);
     2015#endif
     2016        for (bytesLeft = imgPtr->bytesLeft; bytesLeft > 0; /*empty*/) {
     2017            ssize_t numWritten;
    20182018#if WRITE_DEBUG
    2019             DEBUG("image %d: bytesLeft=%d", imgPtr->id, bytesLeft);
    2020 #endif
    2021             numWritten = write(fd, imgPtr->data + imgPtr->numWritten, bytesLeft);
     2019            DEBUG("image %d: bytesLeft=%d", imgPtr->id, bytesLeft);
     2020#endif
     2021            numWritten = write(fd, imgPtr->data + imgPtr->numWritten, bytesLeft);
    20222022#if WRITE_DEBUG
    2023             DEBUG("image %d: wrote %d bytes.", imgPtr->id, numWritten);
    2024 #endif
    2025             if (numWritten < 0) {
    2026                 ERROR("Error writing fd=%d, %s", fd, strerror(errno));
     2023            DEBUG("image %d: wrote %d bytes.", imgPtr->id, numWritten);
     2024#endif
     2025            if (numWritten < 0) {
     2026                ERROR("Error writing fd=%d, %s", fd, strerror(errno));
    20272027#if WRITE_DEBUG
    2028                 DEBUG("Abnormal exit WriteImages");
    2029 #endif
    2030                 return;
    2031             }
    2032             bytesLeft -= numWritten;
    2033             if (bytesLeft > 0) {
     2028                DEBUG("Abnormal exit WriteImages");
     2029#endif
     2030                return;
     2031            }
     2032            bytesLeft -= numWritten;
     2033            if (bytesLeft > 0) {
    20342034#if WRITE_DEBUG
    2035                 DEBUG("image %d, wrote a short buffer, %d bytes left.",
    2036                       imgPtr->id, bytesLeft);
    2037 #endif
    2038                 /* Wrote a short buffer, means we would block. */
    2039                 imgPtr->numWritten += numWritten;
    2040                 imgPtr->bytesLeft = bytesLeft;
     2035                DEBUG("image %d, wrote a short buffer, %d bytes left.",
     2036                      imgPtr->id, bytesLeft);
     2037#endif
     2038                /* Wrote a short buffer, means we would block. */
     2039                imgPtr->numWritten += numWritten;
     2040                imgPtr->bytesLeft = bytesLeft;
    20412041#if WRITE_DEBUG
    2042                 DEBUG("Abnormal exit WriteImages");
    2043 #endif
    2044                 return;
    2045             }
    2046             imgPtr->numWritten += numWritten;
    2047         }
    2048         /* Check if image is on the head.  */
    2049         listPtr->tailPtr = prevPtr;
    2050         if (prevPtr != NULL) {
    2051             prevPtr->nextPtr = NULL;
    2052         }
    2053         FreeImage(imgPtr);
     2042                DEBUG("Abnormal exit WriteImages");
     2043#endif
     2044                return;
     2045            }
     2046            imgPtr->numWritten += numWritten;
     2047        }
     2048        /* Check if image is on the head.  */
     2049        listPtr->tailPtr = prevPtr;
     2050        if (prevPtr != NULL) {
     2051            prevPtr->nextPtr = NULL;
     2052        }
     2053        FreeImage(imgPtr);
    20542054    }
    20552055    listPtr->headPtr = NULL;
     
    20612061
    20622062static void
    2063 ChildHandler(int sigNum) 
     2063ChildHandler(int sigNum)
    20642064{
    20652065    ERROR("pymol (%d) died unexpectedly", stats.pid);
     
    20742074
    20752075static CmdProc cmdProcs[] = {
    2076     { "cartoon",        CartoonCmd        },       
    2077     { "cartoontrace",   CartoonTraceCmd   }, 
    2078     { "clientinfo",     ClientInfoCmd     }, 
    2079     { "disable",        DisableCmd        },       
    2080     { "enable",         EnableCmd         },       
    2081     { "frame",          FrameCmd          },         
    2082     { "label",          LabelCmd          },         
    2083     { "loadpdb",        LoadPDBCmd        },       
    2084     { "orthoscopic",    OrthoscopicCmd    },   
    2085     { "pan",            PanCmd            },           
    2086     { "png",            PngCmd            },           
    2087     { "ppm",            PpmCmd            },           
    2088     { "print",          PrintCmd          },         
    2089     { "raw",            RawCmd            },           
     2076    { "cartoon",        CartoonCmd        },
     2077    { "cartoontrace",   CartoonTraceCmd   },
     2078    { "clientinfo",     ClientInfoCmd     },
     2079    { "disable",        DisableCmd        },
     2080    { "enable",         EnableCmd         },
     2081    { "frame",          FrameCmd          },
     2082    { "label",          LabelCmd          },
     2083    { "loadpdb",        LoadPDBCmd        },
     2084    { "orthoscopic",    OrthoscopicCmd    },
     2085    { "pan",            PanCmd            },
     2086    { "png",            PngCmd            },
     2087    { "ppm",            PpmCmd            },
     2088    { "print",          PrintCmd          },
     2089    { "raw",            RawCmd            },
    20902090    { "representation", RepresentationCmd },
    2091     { "reset",          ResetCmd          },         
    2092     { "rock",           RockCmd           },         
    2093     { "rotate",         RotateCmd         },       
    2094     { "screen",         ScreenCmd         },       
    2095     { "spherescale",    SphereScaleCmd    },   
    2096     { "stickradius",    StickRadiusCmd    },   
    2097     { "transparency",   TransparencyCmd   }, 
    2098     { "viewport",       ScreenCmd         },       
    2099     { "vmouse",         VMouseCmd         },       
    2100     { "zoom",           ZoomCmd           },         
    2101     { NULL,             NULL              }
     2091    { "reset",          ResetCmd          },
     2092    { "rock",           RockCmd           },
     2093    { "rotate",         RotateCmd         },
     2094    { "screen",         ScreenCmd         },
     2095    { "spherescale",    SphereScaleCmd    },
     2096    { "stickradius",    StickRadiusCmd    },
     2097    { "transparency",   TransparencyCmd   },
     2098    { "viewport",       ScreenCmd         },
     2099    { "vmouse",         VMouseCmd         },
     2100    { "zoom",           ZoomCmd           },
     2101    { NULL,             NULL              }
    21022102};
    21032103
     
    21052105InitProxy(PymolProxy *p, char *const *argv)
    21062106{
    2107     int sin[2], sout[2];                /* Pipes to connect to server. */
     2107    int sin[2], sout[2]; /* Pipes to connect to server. */
    21082108    pid_t child;
    21092109    struct timeval end;
     
    21312131    }
    21322132
    2133     if (child == 0) {                   /* Child process */
     2133    if (child == 0) {  /* Child process */
    21342134        int f;
    2135         char tmpname[200];
    2136 
    2137         /* 
     2135        char tmpname[200];
     2136
     2137        /*
    21382138         * Create a new process group, so we can later kill this process and
    21392139         * all its children without affecting the process that created this
    21402140         * one.
    21412141         */
    2142         setpgid(child, 0); 
    2143        
    2144         /* Redirect stdin, stdout, and stderr to pipes before execing */ 
    2145 
    2146         dup2(sin[0],  0);               /* Server standard input */
    2147         dup2(sout[1], 1);               /* Server standard output */
    2148 
    2149         /* Redirect child's stdout to a log file. */
    2150         sprintf(tmpname, "%s/PYMOL-%d-stderr.XXXXXX", LOGDIR, getpid());
    2151         f = mkstemp(tmpname);
    2152         if (f < 0) {
    2153             ERROR("can't open file `%s' to capture pymol stderr: %s", tmpname,
    2154                   strerror(errno));
    2155             exit(1);
    2156         }
    2157         dup2(f, 2);                     /* Redirect stderr to a log file */
    2158        
    2159         /* Close all other descriptors  */       
    2160         for (f = 3; f < FD_SETSIZE; f++) {
     2142        setpgid(child, 0);
     2143
     2144        /* Redirect stdin, stdout, and stderr to pipes before execing */
     2145
     2146        dup2(sin[0],  0); /* Server standard input */
     2147        dup2(sout[1], 1); /* Server standard output */
     2148
     2149        /* Redirect child's stderr to a log file. */
     2150        sprintf(tmpname, "%s/PYMOL-%d-stderr.XXXXXX", LOGDIR, getpid());
     2151        f = mkstemp(tmpname);
     2152        if (f < 0) {
     2153            ERROR("can't open file `%s' to capture pymol stderr: %s", tmpname,
     2154                  strerror(errno));
     2155            exit(1);
     2156        }
     2157        dup2(f, 2);  /* Redirect stderr to a log file */
     2158
     2159        /* Close all other descriptors  */
     2160        for (f = 3; f < FD_SETSIZE; f++) {
    21612161            close(f);
    2162         }
     2162        }
    21632163        INFO("attempting to start \"%s\"", argv[0]);
    21642164        execvp(argv[0], argv);
    21652165        ERROR("can't exec `%s': %s", argv[0], strerror(errno));
    2166         exit(-1);
     2166        exit(-1);
    21672167    } else {
    2168         pymolIsAlive = TRUE;
    2169         signal(SIGCHLD, ChildHandler);
     2168        pymolIsAlive = TRUE;
     2169        signal(SIGCHLD, ChildHandler);
    21702170    }
    21712171    stats.pid = child;
     
    21912191    /* Create safe interpreter and add pymol-specific commands to it. */
    21922192    {
    2193         Tcl_Interp *interp;
    2194         CmdProc *cp;
    2195 
    2196         interp = Tcl_CreateInterp();
    2197         Tcl_MakeSafe(interp);
    2198 
    2199         for (cp = cmdProcs; cp->name != NULL; cp++) {
     2193        Tcl_Interp *interp;
     2194        CmdProc *cp;
     2195
     2196        interp = Tcl_CreateInterp();
     2197        Tcl_MakeSafe(interp);
     2198
     2199        for (cp = cmdProcs; cp->name != NULL; cp++) {
    22002200#if DEBUG
    2201             DEBUG("Adding command %s\n", cp->name);
    2202 #endif
    2203             Tcl_CreateCommand(interp, cp->name, cp->proc, p, NULL);
    2204         }
    2205         p->interp = interp;
     2201            DEBUG("Adding command %s\n", cp->name);
     2202#endif
     2203            Tcl_CreateCommand(interp, cp->name, cp->proc, p, NULL);
     2204        }
     2205        p->interp = interp;
    22062206    }
    22072207    gettimeofday(&end, NULL);
     
    22362236    DEBUG("attempting to signal (SIGTERM) pymol server.");
    22372237#endif
    2238     kill(-p->pid, SIGTERM);             // Kill process group
     2238    kill(-p->pid, SIGTERM); /* Kill process group */
    22392239    alarm(5);
    2240    
     2240
    22412241#if DEBUG
    22422242    DEBUG("Waiting for pymol server to exit after SIGTERM");
    22432243#endif
    22442244    if (waitpid(p->pid, &result, 0) < 0) {
    2245         if (errno != ECHILD) {
    2246             ERROR("error waiting on pymol server to exit after SIGTERM: %s",
    2247                   strerror(errno));
    2248         }
     2245        if (errno != ECHILD) {
     2246            ERROR("error waiting on pymol server to exit after SIGTERM: %s",
     2247                  strerror(errno));
     2248        }
    22492249    }
    22502250    status = -1;
    22512251    while ((status == -1) && (errno == EINTR)) {
    22522252#if DEBUG
    2253         DEBUG("Attempting to signal (SIGKILL) pymol server.");
    2254 #endif
    2255         kill(-p->pid, SIGKILL);         // Kill process group
    2256         alarm(10);
     2253        DEBUG("Attempting to signal (SIGKILL) pymol server.");
     2254#endif
     2255        kill(-p->pid, SIGKILL); /* Kill process group */
     2256        alarm(10);
    22572257#if DEBUG
    2258         DEBUG("Waiting for pymol server to exit after SIGKILL");
    2259 #endif
    2260         status = waitpid(p->pid, &result, 0);
    2261         alarm(0);
     2258        DEBUG("Waiting for pymol server to exit after SIGKILL");
     2259#endif
     2260        status = waitpid(p->pid, &result, 0);
     2261        alarm(0);
    22622262    }
    22632263    INFO("pymol server process ended (result=%d)", result);
    22642264
    22652265    if (WIFEXITED(result)) {
    2266         result = WEXITSTATUS(result);
     2266        result = WEXITSTATUS(result);
    22672267    }
    22682268    return result;
     
    22822282    Tcl_DStringInit(&command);
    22832283    while (pymolIsAlive) {
    2284         tvPtr = NULL;
     2284        tvPtr = NULL;
    22852285#if READ_DEBUG
    2286         DEBUG("Start I/O set");
    2287 #endif
    2288         while ((pymolIsAlive) && (WaitForNextLine(&p->client, tvPtr))) {
    2289             size_t numBytes;
    2290             const char *line;
    2291             int status;
    2292 
    2293             status = GetLine(&p->client, &numBytes, &line);
    2294             if (status != BUFFER_OK) {
    2295                 ERROR("can't read client stdout (numBytes=%d): %s\n", numBytes,
    2296                       strerror(errno));
    2297                 goto done;
    2298             }
    2299             Tcl_DStringAppend(&command, line, numBytes);
    2300             if (Tcl_CommandComplete(Tcl_DStringValue(&command))) {
    2301                 int result;
    2302                    
    2303                 /* May execute more than one command. */
    2304                 result = ExecuteCommand(p->interp, &command);
    2305                 if (result == TCL_BREAK) {
     2286        DEBUG("Start I/O set");
     2287#endif
     2288        while ((pymolIsAlive) && (WaitForNextLine(&p->client, tvPtr))) {
     2289            size_t numBytes;
     2290            const char *line;
     2291            int status;
     2292
     2293            status = GetLine(&p->client, &numBytes, &line);
     2294            if (status != BUFFER_OK) {
     2295                ERROR("can't read client stdout (numBytes=%d): %s\n", numBytes,
     2296                      strerror(errno));
     2297                goto done;
     2298            }
     2299            Tcl_DStringAppend(&command, line, numBytes);
     2300            if (Tcl_CommandComplete(Tcl_DStringValue(&command))) {
     2301                int result;
     2302
     2303                /* May execute more than one command. */
     2304                result = ExecuteCommand(p->interp, &command);
     2305                if (result == TCL_BREAK) {
    23062306#if READ_DEBUG
    2307                     DEBUG("TCL_BREAK found");
    2308 #endif
    2309                     break;              /* This was caused by a "imgflush"
     2307                    DEBUG("TCL_BREAK found");
     2308#endif
     2309                    break;              /* This was caused by a "imgflush"
    23102310                                         * command. Break out of the read
    23112311                                         * loop and allow a new image to be
    23122312                                         * rendered. */
    2313                 }
    2314                 if (p->flags & FORCE_UPDATE) {
     2313                }
     2314                if (p->flags & FORCE_UPDATE) {
    23152315#if READ_DEBUG
    2316                     DEBUG("FORCE_UPDATE set");
    2317 #endif
    2318                     break;
    2319                 }
    2320             }
    2321             tv.tv_sec = 0L;
    2322             tv.tv_usec = 0L;            /* On successive reads, we break
     2316                    DEBUG("FORCE_UPDATE set");
     2317#endif
     2318                    break;
     2319                }
     2320            }
     2321            tv.tv_sec = 0L;
     2322            tv.tv_usec = 0L;            /* On successive reads, we break
    23232323                                         * out if no data is available. */
    2324             tvPtr = &tv;                       
    2325         }
     2324            tvPtr = &tv;
     2325        }
    23262326#if READ_DEBUG
    2327         DEBUG("Finish I/O set");
    2328 #endif
    2329         /* Handle all the pending setting changes now. */
    2330         UpdateSettings(p);
    2331 
    2332         /* We might want to refresh the image if we're not currently
    2333         * transmitting an image back to the client. The image will be
    2334         * refreshed after the image has been completely transmitted. */
    2335         if (p->flags & UPDATE_PENDING) {
     2327        DEBUG("Finish I/O set");
     2328#endif
     2329        /* Handle all the pending setting changes now. */
     2330        UpdateSettings(p);
     2331
     2332        /* We might want to refresh the image if we're not currently
     2333        * transmitting an image back to the client. The image will be
     2334        * refreshed after the image has been completely transmitted. */
     2335        if (p->flags & UPDATE_PENDING) {
    23362336#if READ_DEBUG
    2337             DEBUG("calling ppm because of update");
    2338 #endif
    2339             Tcl_Eval(p->interp, "ppm");
    2340             p->flags &= ~(UPDATE_PENDING|FORCE_UPDATE);
    2341         }
     2337            DEBUG("calling ppm because of update");
     2338#endif
     2339            Tcl_Eval(p->interp, "ppm");
     2340            p->flags &= ~(UPDATE_PENDING|FORCE_UPDATE);
     2341        }
    23422342    }
    23432343 done:
     
    23592359    list.headPtr = list.tailPtr = NULL;
    23602360    while (pymolIsAlive) {
    2361         while (WaitForNextLine(bp, NULL)) {
    2362             Image *imgPtr;
    2363             const char *line;
    2364             char header[200];
    2365             size_t len;
    2366             int numBytes;
    2367             size_t hdrLength;
    2368             int frameNum, rockOffset;
    2369             char cacheId[200];
    2370 
    2371             /* Keep reading lines untils we find a "image follows:" line */
    2372             if (GetLine(bp, &len, &line) != BUFFER_OK) {
     2361        while (WaitForNextLine(bp, NULL)) {
     2362            Image *imgPtr;
     2363            const char *line;
     2364            char header[200];
     2365            size_t len;
     2366            int numBytes;
     2367            size_t hdrLength;
     2368            int frameNum, rockOffset;
     2369            char cacheId[200];
     2370
     2371            /* Keep reading lines untils we find a "image follows:" line */
     2372            if (GetLine(bp, &len, &line) != BUFFER_OK) {
    23732373#if WRITE_DEBUG
    2374                 DEBUG("Leaving Writer thread");
    2375 #endif
    2376                 return NULL;
    2377             }
     2374                DEBUG("Leaving Writer thread");
     2375#endif
     2376                return NULL;
     2377            }
    23782378#if WRITE_DEBUG
    2379             DEBUG("Writer: line found is %s\n", line);
    2380 #endif
    2381             if (strncmp(line, "image follows: ", 15) != 0) {
    2382                 continue;
    2383             }
    2384             if (sscanf(line, "image follows: %d %s %d %d\n", &numBytes, cacheId,
    2385                        &frameNum, &rockOffset) != 4) {
    2386                 ERROR("can't get # bytes from \"%s\"", line);
    2387                 DEBUG("Leaving Writer thread");
    2388                 return NULL;
    2389             }
     2379            DEBUG("Writer: line found is %s\n", line);
     2380#endif
     2381            if (strncmp(line, "image follows: ", 15) != 0) {
     2382                continue;
     2383            }
     2384            if (sscanf(line, "image follows: %d %s %d %d\n", &numBytes, cacheId,
     2385                       &frameNum, &rockOffset) != 4) {
     2386                ERROR("can't get # bytes from \"%s\"", line);
     2387                DEBUG("Leaving Writer thread");
     2388                return NULL;
     2389            }
    23902390#if WRITE_DEBUG
    2391             DEBUG("found image line \"%.*s\"", numBytes, line);
    2392 #endif
    2393             sprintf(header, "nv>image %d %s %d %d\n", numBytes, cacheId,
    2394                     frameNum, rockOffset);
    2395             hdrLength = strlen(header);
     2391            DEBUG("found image line \"%.*s\"", numBytes, line);
     2392#endif
     2393            sprintf(header, "nv>image %d %s %d %d\n", numBytes, cacheId,
     2394                    frameNum, rockOffset);
     2395            hdrLength = strlen(header);
    23962396#if WRITE_DEBUG
    2397             DEBUG("Queueing image numBytes=%d cacheId=%s, frameNum=%d, rockOffset=%d size=%d\n", numBytes, cacheId, frameNum, rockOffset, numBytes + hdrLength);
    2398 #endif
    2399             imgPtr = NewImage(&list, numBytes + hdrLength);
    2400             memcpy(imgPtr->data, header, hdrLength);
    2401             if (ReadFollowingData(bp, imgPtr->data + hdrLength,
    2402                         (size_t)numBytes) != BUFFER_OK) {
    2403                 ERROR("can't read %d bytes for \"image follows\" buffer: %s",
    2404                       numBytes, strerror(errno));
     2397            DEBUG("Queueing image numBytes=%d cacheId=%s, frameNum=%d, rockOffset=%d size=%d\n", numBytes, cacheId, frameNum, rockOffset, numBytes + hdrLength);
     2398#endif
     2399            imgPtr = NewImage(&list, numBytes + hdrLength);
     2400            memcpy(imgPtr->data, header, hdrLength);
     2401            if (ReadFollowingData(bp, imgPtr->data + hdrLength,
     2402                        (size_t)numBytes) != BUFFER_OK) {
     2403                ERROR("can't read %d bytes for \"image follows\" buffer: %s",
     2404                      numBytes, strerror(errno));
    24052405#if WRITE_DEBUG
    2406                 DEBUG("Leaving Writer thread");
    2407 #endif
    2408                 return NULL;
    2409             }
    2410             stats.numFrames++;
    2411             stats.numBytes += numBytes;
    2412             {
    2413                 struct timeval tv;
    2414                 fd_set writeFds;
    2415 
    2416                 tv.tv_sec = tv.tv_usec = 0L;
    2417                 FD_ZERO(&writeFds);
    2418                 FD_SET(CLIENT_WRITE, &writeFds);
    2419                 if (select(CLIENT_WRITE+1, NULL, &writeFds, NULL, &tv) > 0) {
    2420                     WriteImages(&list, CLIENT_WRITE);
    2421                 }
    2422             }
    2423         }
     2406                DEBUG("Leaving Writer thread");
     2407#endif
     2408                return NULL;
     2409            }
     2410            stats.numFrames++;
     2411            stats.numBytes += numBytes;
     2412            {
     2413                struct timeval tv;
     2414                fd_set writeFds;
     2415
     2416                tv.tv_sec = tv.tv_usec = 0L;
     2417                FD_ZERO(&writeFds);
     2418                FD_SET(CLIENT_WRITE, &writeFds);
     2419                if (select(CLIENT_WRITE+1, NULL, &writeFds, NULL, &tv) > 0) {
     2420                    WriteImages(&list, CLIENT_WRITE);
     2421                }
     2422            }
     2423        }
    24242424    }
    24252425#if WRITE_DEBUG
     
    24402440    frecord = NULL;
    24412441    if (recording) {
    2442         char fileName[200];
    2443 
    2444         sprintf(fileName, "/tmp/pymolproxy%d.py", getpid());
     2442        char fileName[200];
     2443
     2444        sprintf(fileName, "/tmp/pymolproxy%d.py", getpid());
    24452445        frecord = fopen(fileName, "w");
    24462446    }   
     
    24622462    if (pthread_join(thread1, NULL) < 0) {
    24632463        ERROR("Can't join reader thread: %s", strerror(errno));
    2464     } 
     2464    }
    24652465    return FreeProxy(&proxy);
    24662466}
Note: See TracChangeset for help on using the changeset viewer.