IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4612


Ignore:
Timestamp:
Jul 26, 2005, 10:00:57 AM (21 years ago)
Author:
drobbin
Message:

changed p_psDBRunQuery to accept a variable argument list (as requested in rev 15)

Location:
trunk/psLib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/pslib.kdevses

    r4608 r4612  
    33<KDevPrjSession>
    44 <DocsAndViews NumberOfDocuments="4" >
    5   <Doc0 NumberOfViews="1" URL="file:/home/drobbin/panstarrs/new/psLib/src/math/psMinimize.h" >
    6    <View0 line="74" Type="Source" />
     5  <Doc0 NumberOfViews="1" URL="file:/home/drobbin/panstarrs/new/psLib/src/db/psDB.h" >
     6   <View0 Type="Source" />
    77  </Doc0>
    8   <Doc1 NumberOfViews="1" URL="file:/home/drobbin/panstarrs/new/psLib/src/math/psMinimize.c" >
    9    <View0 line="1568" Type="Source" />
     8  <Doc1 NumberOfViews="1" URL="file:/home/drobbin/panstarrs/new/psLib/src/db/psDB.c" >
     9   <View0 Type="Source" />
    1010  </Doc1>
    11   <Doc2 NumberOfViews="1" URL="file:/home/drobbin/panstarrs/new/psLib/src/imageops/psImageGeomManip.h" >
    12    <View0 line="145" Type="Source" />
     11  <Doc2 NumberOfViews="1" URL="file:/home/drobbin/panstarrs/new/psLib/src/sys/psString.h" >
     12   <View0 Type="Source" />
    1313  </Doc2>
    14   <Doc3 NumberOfViews="1" URL="file:/home/drobbin/panstarrs/new/psLib/src/imageops/psImageGeomManip.c" >
    15    <View0 line="690" Type="Source" />
     14  <Doc3 NumberOfViews="1" URL="file:/home/drobbin/panstarrs/new/psLib/src/sys/psString.c" >
     15   <View0 line="83" Type="Source" />
    1616  </Doc3>
    1717 </DocsAndViews>
  • trunk/psLib/src/db/psDB.c

    r4589 r4612  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-07-21 01:40:10 $
     14 *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-07-26 20:00:57 $
    1616 *
    1717 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    853853
    854854bool p_psDBRunQuery(psDB *dbh,
    855                     const char *format)
    856 {
     855                    const char *format,
     856                    ...)
     857{
     858    va_list argPtr;
     859    char *dest = NULL;
     860
    857861    // Verify database object is not NULL
    858862    if(dbh == NULL) {
     
    862866
    863867    // Run query
    864     if (mysql_real_query(dbh->mysql, format, (unsigned long)strlen(format)) !=0) {
     868    va_start(argPtr, format);
     869    if(argPtr == NULL) {
     870        dest=psStringCopy(format);
     871    } else {
     872        int destSize = vsnprintf(dest, 0, format, argPtr);
     873        dest = psAlloc(destSize+1);
     874        vsnprintf(dest, destSize+1, format, argPtr);
     875    }
     876    va_end(argPtr);
     877    if (mysql_real_query(dbh->mysql, dest, (unsigned long)strlen(dest)) !=0) {
    865878        psError(PS_ERR_UNKNOWN, true, PS_ERRORTEXT_psDB_SQL_QUERY_FAIL, mysql_error(dbh->mysql));
     879        psFree(dest);
    866880        return false;
    867881    }
    868882
     883    psFree(dest);
    869884    return true;
    870885}
  • trunk/psLib/src/db/psDB.h

    r4589 r4612  
    1010 *  @author Joshua Hoblitt
    1111 *
    12  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-07-21 01:40:10 $
     12 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-07-26 20:00:57 $
    1414 *
    1515 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    9292bool p_psDBRunQuery(
    9393    psDB *dbh,                         ///< Database handle
    94     const char *format                 ///< SQL string to execute
     94    const char *format,                ///< SQL string to execute
     95    ...                                ///< Arguments for name formatting and metadata item data.
    9596);
    9697
Note: See TracChangeset for help on using the changeset viewer.