Changeset 6606


Ignore:
Timestamp:
Nov 11, 2016 12:43:23 AM (8 years ago)
Author:
ldelgass
Message:

merge r6598:6605 from pymolproxy trunk

Location:
pymolproxy/branches/1.0
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pymolproxy/branches/1.0

  • pymolproxy/branches/1.0/Makefile.in

    r4592 r6606  
    6464
    6565clean:
    66         $(RM) a.out *.o *~ core* $(TARGETS) *.log *.tmp logfile* .deps/*.d
     66        $(RM) a.out *.o *~ core* $(TARGETS) .deps/*.d
    6767
    6868distclean: clean
  • pymolproxy/branches/1.0/pymolproxy.c

    r6399 r6606  
    1212 * image rendered offscreen is returned as ppm-formatted image data.
    1313 *
    14  *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
     14 *  Copyright (c) 2004-2016  HUBzero Foundation, LLC
    1515 *
    1616 *  See the file "license.terms" for information on usage and
    1717 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1818 * ======================================================================
     19 *
     20 * Authors:
     21 *   Nicholas Kisseberth <nkissebe@purdue.edu>
     22 *   George A. Howlett <gah@purdue.edu>
     23 *   Leif Delgass <ldelgass@purdue.edu>
    1924 */
    2025
     
    124129#endif /* LOGDIR */
    125130
     131#ifndef STATSDIR
     132#define STATSDIR "/var/tmp/visservers"
     133#endif  /*STATSDIR*/
     134
    126135#define CVT2SECS(x)  ((double)(x).tv_sec) + ((double)(x).tv_usec * 1.0e-6)
    127136
     
    191200    int rockOffset;
    192201    int cacheId;
    193     int error;
    194202    int status;
    195203    int width, height;                  /* Size of viewport. */
     
    228236#if WANT_DEBUG
    229237static void
    230 PrintToLog TCL_VARARGS_DEF(const char *, arg1)
    231 {
    232     const char *format;
     238PrintToLog(const char *format, ...)
     239{
    233240    va_list args;
    234241
    235     format = TCL_VARARGS_START(const char *, arg1, args);
     242    va_start(args, format);
    236243    fprintf(stderr, "pymolproxy: ");
    237244    vfprintf(stderr, format, args);
     245    va_end(args);
    238246    fprintf(stderr, "\n");
    239247    fflush(stderr);
     
    261269    length += vsnprintf(message + length, MSG_LEN - length, fmt, lst);
    262270    message[MSG_LEN] = '\0';
     271    va_end(lst);
     272
    263273    if (debug) {
    264         DEBUG("%s\n", message);
     274        DEBUG("%s", message);
    265275    } else {
    266276        syslog(priority, message, length);
     
    269279
    270280static void
    271 Record TCL_VARARGS_DEF(const char *, arg1)
    272 {
    273     const char *format;
     281Record(const char *format, ...)
     282{
    274283    va_list args;
    275284
    276     format = TCL_VARARGS_START(const char *, arg1, args);
     285    va_start(args, format);
    277286    vfprintf(frecord, format, args);
     287    va_end(args);
    278288    fflush(frecord);
    279289}
     
    288298    size_t length;
    289299
    290     if (proxyPtr->error) {
    291         return TCL_ERROR;
    292     }
    293 
    294300    va_start(ap, format);
    295     result = vsnprintf(buffer, BUFSIZ-1, format, ap);
     301    result = vsnprintf(buffer, BUFSIZ, format, ap);
    296302    va_end(ap);
    297 
    298 #ifdef EXEC_DEBUG
    299     DEBUG("to-pymol>(%s) code=%d", buffer, result);
     303    if (result >= BUFSIZ) {
     304        ERROR("Buffer too small for command (len=%d)", result);
     305        proxyPtr->status = TCL_ERROR;
     306        return proxyPtr->status;
     307    }
     308
     309#if EXEC_DEBUG
     310    DEBUG("to-pymol>(%s) len=%d", buffer, result);
    300311#endif
    301312    if (recording) {
     
    309320        ERROR("short write to pymol (wrote=%d, should have been %d): %s",
    310321              numWritten, length, strerror(errno));
    311     }
    312     proxyPtr->status = result;
    313     return  proxyPtr->status;
    314 }
    315 
    316 
    317 
    318 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    319 /*
    320  * Copyright (C) 2011, Purdue Research Foundation
    321  *
    322  * Author: George A. Howlett <gah@purdue.edu>
    323  */
     322        proxyPtr->status = TCL_ERROR;
     323    }
     324    return proxyPtr->status;
     325}
    324326
    325327static void
     
    550552clear_error(PymolProxy *proxyPtr)
    551553{
    552     proxyPtr->error = 0;
    553554    proxyPtr->status = TCL_OK;
    554555}
    555 
    556 #ifndef STATSDIR
    557 #define STATSDIR "/var/tmp/visservers"
    558 #endif  /*STATSDIR*/
    559556
    560557static int
     
    733730}
    734731
    735 
    736732static int
    737733CartoonCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     
    842838    return p->status;
    843839}
    844 
    845840
    846841static int
     
    12691264}
    12701265
    1271 
    12721266static int
    12731267PpmCmd(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])
     
    12911285    return p->status;
    12921286}
    1293 
    12941287
    12951288static int
     
    17981791}
    17991792
    1800 
    18011793/*
    18021794 * ZoomCmd --
     
    18481840}
    18491841
    1850 
    1851 
    18521842static int
    18531843ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr)
     
    18661856    if (result != TCL_OK) {
    18671857#if EXEC_DEBUG
    1868         DEBUG("result was %s\n", Tcl_GetString(Tcl_GetObjResult(interp)));
     1858        DEBUG("result was %s", Tcl_GetString(Tcl_GetObjResult(interp)));
    18691859#endif
    18701860    }
     
    19981988}
    19991989
    2000 
    20011990static void
    20021991WriteImages(ImageList *listPtr, int fd)
     
    20642053#endif
    20652054}
    2066 
    20672055
    20682056static void
     
    21162104
    21172105#if DEBUG
    2118     DEBUG("Entering InitProxy\n");
     2106    DEBUG("Entering InitProxy");
    21192107#endif
    21202108    /* Create two pipes for communication with the external application. One
     
    21332121    child = fork();
    21342122    if (child < 0) {
    2135         ERROR("can't fork process: %s\n", strerror(errno));
     2123        ERROR("can't fork process: %s", strerror(errno));
    21362124        return -3;
    21372125    }
     
    21672155            close(f);
    21682156        }
    2169         INFO("attempting to start \"%s\"", argv[0]);
     2157        INFO("Executing \"%s\"", argv[0]);
    21702158        execvp(argv[0], argv);
    21712159        ERROR("can't exec `%s': %s", argv[0], strerror(errno));
     
    21782166
    21792167#if DEBUG
    2180     DEBUG("Started %s DISPLAY=%s\n", argv[0], getenv("DISPLAY"));
     2168    DEBUG("Started %s DISPLAY=%s", argv[0], getenv("DISPLAY"));
    21812169#endif
    21822170    /* close opposite end of pipe, these now belong to the child process  */
     
    22052193        for (cp = cmdProcs; cp->name != NULL; cp++) {
    22062194#if DEBUG
    2207             DEBUG("Adding command %s\n", cp->name);
     2195            DEBUG("Adding command %s", cp->name);
    22082196#endif
    22092197            Tcl_CreateCommand(interp, cp->name, cp->proc, p, NULL);
     
    22742262    return result;
    22752263}
    2276 
    22772264
    22782265static void *
     
    22992286            status = GetLine(&p->client, &numBytes, &line);
    23002287            if (status != BUFFER_OK) {
    2301                 ERROR("can't read client stdout (numBytes=%d): %s\n", numBytes,
     2288                ERROR("can't read client stdout (numBytes=%d): %s", numBytes,
    23022289                      strerror(errno));
    23032290                goto done;
     
    23832370            }
    23842371#if WRITE_DEBUG
    2385             DEBUG("Writer: line found is %s\n", line);
     2372            DEBUG("Writer: line found is \"%.*s\"", (int)len, line);
    23862373#endif
    23872374            if (strncmp(line, "image follows: ", 15) != 0) {
     
    23902377            if (sscanf(line, "image follows: %d %s %d %d\n", &numBytes, cacheId,
    23912378                       &frameNum, &rockOffset) != 4) {
    2392                 ERROR("can't get # bytes from \"%s\"", line);
     2379                ERROR("can't get # bytes from \"%.*s\"", (int)len, line);
    23932380                DEBUG("Leaving Writer thread");
    23942381                return NULL;
    23952382            }
    23962383#if WRITE_DEBUG
    2397             DEBUG("found image line \"%.*s\"", numBytes, line);
     2384            DEBUG("found image line (%d bytes)", numBytes);
    23982385#endif
    23992386            sprintf(header, "nv>image %d %s %d %d\n", numBytes, cacheId,
     
    24012388            hdrLength = strlen(header);
    24022389#if WRITE_DEBUG
    2403             DEBUG("Queueing image numBytes=%d cacheId=%s, frameNum=%d, rockOffset=%d size=%d\n", numBytes, cacheId, frameNum, rockOffset, numBytes + hdrLength);
     2390            DEBUG("Queueing image numBytes=%d cacheId=%s, frameNum=%d, rockOffset=%d size=%d", numBytes, cacheId, frameNum, rockOffset, numBytes + hdrLength);
    24042391#endif
    24052392            imgPtr = NewImage(&list, numBytes + hdrLength);
     
    24572444        ERROR("Short write on version string", strerror(errno));
    24582445    }
    2459     INFO("Starting pymolproxy (threaded version)");
     2446    DEBUG("Starting pymolproxy");
    24602447
    24612448    InitProxy(&proxy, argv + 1);
Note: See TracChangeset for help on using the changeset viewer.