IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4944


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

made requested changes including using file descriptors in psTrace

Location:
trunk/psLib
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psTime.c

    r4937 r4944  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-08-31 22:28:35 $
     12 *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-09-02 21:32:03 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    13601360}
    13611361
    1362 psTime* psTimeFromISO(const char *input)
     1362psTime* psTimeFromISO(const char *input,
     1363                      psTimeType type)
    13631364{
    13641365    psS32 millisecond;
     
    13911392    outTime = p_psTimeFromTM(&tmTime);
    13921393    outTime->nsec = millisecond * 1000000;
     1394    outTime->type = type;
    13931395
    13941396    return outTime;
  • trunk/psLib/src/astro/psTime.h

    r4937 r4944  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-08-31 22:28:35 $
     13 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-09-02 21:32:03 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    281281 */
    282282psTime* psTimeFromISO(
    283     const char* input                  ///< Input time to be converted.
     283    const char* input,                 ///< Input time to be converted.
     284    psTimeType type                    ///< Time type.
    284285);
    285286
  • trunk/psLib/src/math/psMinimize.c

    r4898 r4944  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.132 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-08-30 01:14:13 $
     11 *  @version $Revision: 1.133 $ $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
     
    21922192
    21932193    if (psTraceGetLevel (".psLib.dataManip.VectorFitPolynomial1DOrd") >= 5) {
    2194         FILE *f = psTraceGetDestination ();
     2194        FILE *f = fdopen((psTraceGetDestination ()), "a+");
    21952195        fprintf (f, "VectorFitPolynomial1D()\n");
    21962196        for (int i = 0; i < x->n; i++) {
    21972197            fprintf (f, "(x, y, yErr) is (%f, %f, %f)\n", x->data.F64[i], y->data.F64[i], yErr->data.F64[i]);
    21982198        }
     2199        fclose(f);
    21992200    }
    22002201
  • trunk/psLib/src/mathtypes/psImage.c

    r4920 r4944  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.79 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-08-31 02:07:11 $
     11 *  @version $Revision: 1.80 $ $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
     
    473473}
    474474
    475 bool p_psImagePrint (FILE *f, psImage *a, char *name)
    476 {
    477 
     475bool p_psImagePrint (int fd, psImage *a, char *name)
     476{
     477    FILE *f;
     478    f = fdopen(fd, "a+");
    478479    fprintf (f, "matrix: %s\n", name);
    479480
     
    485486    }
    486487    fprintf (f, "\n");
     488    fclose(f);
    487489    return (true);
    488490}
  • trunk/psLib/src/mathtypes/psImage.h

    r4920 r4944  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-08-31 02:07:11 $
     13 *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-09-02 21:32:06 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    239239 */
    240240bool p_psImagePrint(
    241     FILE *f,                           ///< Destination stream
     241    int fd,                            ///< Destination file descriptor
    242242    psImage *a,                        ///< image to print
    243243    char *name                         ///< name of the image (for title)
  • trunk/psLib/src/mathtypes/psVector.c

    r4898 r4944  
    99*  @author Robert DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-08-30 01:14:13 $
     11*  @version $Revision: 1.51 $ $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
     
    599599}
    600600
    601 bool p_psVectorPrint (FILE *f,
     601bool p_psVectorPrint (int fd,
    602602                      psVector *a,
    603603                      char *name)
    604604{
    605 
     605    FILE *f;
     606    f = fdopen(fd, "a+");
    606607    fprintf (f, "vector: %s\n", name);
    607608
     
    610611    }
    611612    fprintf (f, "\n");
     613    fclose(f);
    612614    return (true);
    613615}
  • trunk/psLib/src/mathtypes/psVector.h

    r4898 r4944  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-08-30 01:14:13 $
     13 *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-09-02 21:32:06 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    192192 */
    193193bool p_psVectorPrint (
    194     FILE *f,                           ///< output stream
     194    int fd,                            ///< output file descriptor
    195195    psVector *a,                       ///< vector to print
    196196    char *name                         ///< name of vector (for title)
  • 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
  • trunk/psLib/src/sys/psTrace.h

    r4610 r4944  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-07-26 00:44:44 $
     11 *  @version $Revision: 1.36 $ $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
     
    106106/// Set the destination of future trace messages.
    107107void psTraceSetDestination(
    108     FILE * fp                          ///< Pointer to file
     108    int fd                             ///< File descriptor
    109109);
    110110
     
    113113 *  @return FILE*:      File Destination
    114114 */
    115 FILE *psTraceGetDestination(void);
     115int psTraceGetDestination(void);
    116116
    117117/* \} */// End of SystemGroup Functions
  • trunk/psLib/test/astro/tst_psTime_01.c

    r4547 r4944  
    2323 *  @author  Eric Van Alst, MHPCC
    2424 *
    25  *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    26  *  @date  $Date: 2005-07-13 02:46:58 $
     25 *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     26 *  @date  $Date: 2005-09-02 21:32:06 $
    2727 *
    2828 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    636636    // Attempt to convert NULL string
    637637    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL ISO string");
    638     time = psTimeFromISO(NULL);
     638    time = psTimeFromISO(NULL, PS_TIME_TAI);
    639639    if(time != NULL) {
    640640        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected for NULL ISO string");
     
    643643
    644644    // Convert valid ISO string
    645     time = psTimeFromISO(testTime1Str);
     645    time = psTimeFromISO(testTime1Str, PS_TIME_TAI);
    646646    if(time->type != PS_TIME_TAI) {
    647647        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
     
    658658    // Attempt to convert invalid ISO string
    659659    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error for invalid ISO string");
    660     time = psTimeFromISO("Here I am");
     660    time = psTimeFromISO("Here I am", PS_TIME_TAI);
    661661    if(time != NULL) {
    662662        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected for invalid ISO string");
  • trunk/psLib/test/sys/tst_psTrace.c

    r4547 r4944  
    88#include "pslib_strict.h"
    99#include "psTest.h"
     10#include <fcntl.h>
     11#include <unistd.h>
    1012
    1113
     
    4951    psS32 lev = 0;
    5052
    51     psTraceSetDestination(stderr);
     53    //    psTraceSetDestination(stderr);
     54    psTraceSetDestination(2);
    5255
    5356    for (i=0;i<10;i++) {
     
    9699static psS32 testTrace01(void)
    97100{
    98     psTraceSetDestination(stderr);
     101    //    psTraceSetDestination(stderr);
     102    psTraceSetDestination(2);
    99103    (void)psTraceSetLevel(".A.B.C.D.E", 5);
    100104
     
    111115{
    112116    psTraceReset();
    113     psTraceSetDestination(stderr);
     117    //    psTraceSetDestination(stderr);
     118    psTraceSetDestination(2);
    114119    psTraceSetLevel(".A.B", 2);
    115120    psTraceSetLevel(".A.B.C.D.E", 5);
     
    142147    psS32 lev = 0;
    143148
    144     psTraceSetDestination(stderr);
     149    //    psTraceSetDestination(stderr);
     150    psTraceSetDestination(2);
    145151
    146152    for (i=0;i<10;i++) {
     
    183189{
    184190    FILE *fp;
     191    int FD;
    185192    psS32 nb = 0;
    186 
    187     fp = fopen("tst_psTrace02_OUT", "w");
     193    FD = creat("tst_psTrace02_OUT", 0666);
     194    //    printf("\nFD = %d\n", FD);
     195    //    fp = fopen("tst_psTrace02_OUT", "w");
     196    fp = fdopen(FD, "w");
    188197    for (nb = 0 ; nb<4;nb++) {
    189198        if (nb == 0)
    190             psTraceSetDestination(stdout);
     199            //            psTraceSetDestination(stdout);
     200            psTraceSetDestination(1);
    191201        if (nb == 1)
    192             psTraceSetDestination(stderr);
     202            //            psTraceSetDestination(stderr);
     203            psTraceSetDestination(2);
    193204        if (nb == 2)
    194             psTraceSetDestination(NULL);
     205            psTraceSetDestination(-1); //NULL
    195206        if (nb == 3)
    196             psTraceSetDestination(fp);
     207            psTraceSetDestination(FD);
    197208
    198209        (void)psTraceSetLevel(".", 4);
     
    221232
    222233    fclose(fp);
     234    close(FD);
    223235
    224236    return(0);
     
    227239static psS32 testTrace05(void)
    228240{
    229     psTraceSetDestination(stderr);
     241    //    psTraceSetDestination(stderr);
     242    psTraceSetDestination(2);
    230243
    231244    (void)psTraceSetLevel(".", 9);
     
    277290static psS32 testTrace06(void)
    278291{
    279     psTraceSetDestination(stderr);
     292    //    psTraceSetDestination(stderr);
     293    psTraceSetDestination(2);
    280294
    281295    (void)psTraceSetLevel(".", 9);
Note: See TracChangeset for help on using the changeset viewer.