IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 2, 2005, 11:32:06 AM (21 years ago)
Author:
drobbin
Message:

made requested changes including using file descriptors in psTrace

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psTrace.c

    r4578 r4944  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-07-18 20:54:22 $
     11 *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-09-02 21:32:06 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5555static p_psComponent* cRoot = NULL; // The root of the trace component
    5656static FILE *traceFP = NULL;        // File destination for messages.
     57//static int traceFD = 0;
    5758
    5859static void componentFree(p_psComponent* comp);
     
    525526
    526527// XXX EAM : I've added code to close the old traceFP (safely)
    527 void psTraceSetDestination(FILE * fp)
    528 {
    529 
    530     bool special;
    531 
    532     // XXX EAM perhaps return an error?
    533     if (fp == NULL) {
     528void psTraceSetDestination(int fd)
     529{
     530
     531
     532    /*
     533        bool special;
     534     
     535        // XXX EAM perhaps return an error?
     536        if (fp == NULL) {
     537            return;
     538        }
     539     
     540        // cannot close traceFP if one of the special FILE ptrs
     541        special  = (traceFP == NULL);
     542        special |= (traceFP == stdin);
     543        special |= (traceFP == stdout);
     544        special |= (traceFP == stderr);
     545     
     546        if (!special) {
     547            fclose (traceFP);
     548        }
     549        traceFP = fp;
     550    */
     551    if (fd == -1) {
    534552        return;
    535553    }
    536 
    537     // cannot close traceFP if one of the special FILE ptrs
    538     special  = (traceFP == NULL);
    539     special |= (traceFP == stdin);
    540     special |= (traceFP == stdout);
    541     special |= (traceFP == stderr);
    542 
    543     if (!special) {
    544         fclose (traceFP);
    545     }
    546     traceFP = fp;
    547 }
    548 
    549 FILE *psTraceGetDestination()
    550 {
    551     if (traceFP == NULL) {
     554    if (fd == 1) {
    552555        traceFP = stdout;
    553     }
    554     return traceFP;
     556    } else if (fd == 2) {
     557        traceFP = stderr;
     558    } else if (fd == 0) {
     559        traceFP = stdin;
     560    } else if (fd > 2) {
     561        traceFP = fdopen(fd, "w");
     562    }
     563}
     564
     565int psTraceGetDestination()
     566{
     567    int fd;
     568    fd = fileno(traceFP);
     569    return fd;
    555570}
    556571
Note: See TracChangeset for help on using the changeset viewer.