---------------------
PatchSet 235 
Date: 2005/05/06 00:42:24
Author: jhoblitt
Branch: HEAD
Tag: (none) 
Log:
move psStringAppend() & psStringPrepend() from psDB.c to psString.c and make them public

Members: 
	src/dataIO/psDB.c:1.1->1.2 
	src/sysUtils/psString.c:1.1->1.2 
	src/sysUtils/psString.h:1.1->1.2 

Index: pslib/src/dataIO/psDB.c
diff -u pslib/src/dataIO/psDB.c:1.1 pslib/src/dataIO/psDB.c:1.2
--- pslib/src/dataIO/psDB.c:1.1	Tue Apr  5 15:12:58 2005
+++ pslib/src/dataIO/psDB.c	Thu May  5 14:42:24 2005
@@ -11,8 +11,8 @@
  *  @author Aaron Culliney
  *  @author Joshua Hoblitt
  *
- *  @version $Revision: 1.1 $ $Name:  $
- *  @date $Date: 2005/04/06 01:12:58 $
+ *  @version $Revision: 1.2 $ $Name:  $
+ *  @date $Date: 2005/05/06 00:42:24 $
  *
  *  Copyright 2005 Joshua Hoblitt, University of Hawaii
  */
@@ -82,8 +82,6 @@
 
 // string utility functions
 static char    *psDBIntToString(psU64 n);
-static ssize_t  psStringAppend(char **dest, const char *format, ...);
-static ssize_t  psStringPrepend(char **dest, const char *format, ...);
 
 
 // public functions
@@ -1611,95 +1609,4 @@
     return string;
 }
 
-static ssize_t psStringAppend(char **dest, const char *format, ...)
-{
-    va_list         args;
-    size_t          length;             // complete string length (sans \0)
-    size_t          oldLength;          // original string length (sans \0)
-    ssize_t         tailLength;         // length of string to append
-
-    if (!*dest) {
-        *dest = psStringCopy("");
-        oldLength = 0;
-    } else {
-        // size of existing string
-        oldLength = strlen(*dest);
-    }
-
-    // find the size of the string to append
-    va_start(args, format);
-    // C99 guarentees vsnprintf() to work as expected with size = 0
-    tailLength = vsnprintf(*dest, 0, format, args);
-    va_end(args);
-
-    // if the new tail is zero length, return the length of the old string.  if
-    // it's a format error, return the error code.
-    if (tailLength < 1) {
-        return tailLength == 0 ? oldLength : tailLength;
-    }
-
-    // new string length (sans \0)
-    length = oldLength + tailLength;
-
-    // realloc string to string + tail + \0
-    *dest = psRealloc(*dest, length + 1);
-
-    // append tail + \0
-    va_start(args, format);
-    vsnprintf(*dest + oldLength, tailLength + 1, format, args);
-    va_end(args);
-
-    return length;
-}
-
-static ssize_t psStringPrepend(char **dest, const char *format, ...)
-{
-    va_list         args;
-    size_t          length;             // complete string length (sans \0)
-    ssize_t         headLength;         // length of string to prepend
-    char            *oldDest;           // copy of original string
-
-    if (!*dest) {
-        // makes the string backup and concatination pointless
-        *dest = psStringCopy("");
-        length = 0;
-    } else {
-        // size of existing string
-        length = strlen(*dest);
-    }
-
-    // find the size of the string to prepend
-    va_start(args, format);
-    // C99 guarentees vsnprintf() to work as expected with size = 0
-    headLength = vsnprintf(*dest, 0, format, args);
-    va_end(args);
-
-    // if the new head is zero length, return the length of the old string.  if
-    // it's a format error, return the error code.
-    if (headLength < 1) {
-        return headLength == 0 ? length : headLength;
-    }
-
-    // backup original string
-    oldDest = psStringCopy(*dest);
-
-    // new string length (sans \0)
-    length += headLength;
-
-    // realloc string to head + string + \0
-    *dest = psRealloc(*dest, length + 1);
-
-    // copy the new head to the beginning of string
-    va_start(args, format);
-    vsnprintf(*dest, length + 1, format, args);
-    va_end(args);
-
-    // append the original string
-    strncat(*dest, oldDest, length + 1);
-
-    psFree(oldDest);
-
-    return length;
-}
-
 #endif // BUILD_PSDB
Index: pslib/src/sysUtils/psString.c
diff -u pslib/src/sysUtils/psString.c:1.1 pslib/src/sysUtils/psString.c:1.2
--- pslib/src/sysUtils/psString.c:1.1	Thu Feb 17 09:26:24 2005
+++ pslib/src/sysUtils/psString.c	Thu May  5 14:42:27 2005
@@ -8,8 +8,8 @@
  *
  *  @author Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name:  $
- *  @date $Date: 2005/02/17 19:26:24 $
+ *  @version $Revision: 1.2 $ $Name:  $
+ *  @date $Date: 2005/05/06 00:42:27 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -54,3 +54,94 @@
     // Return the string pointer
     return returnValue;
 }
+
+ssize_t psStringAppend(char **dest, const char *format, ...)
+{
+    va_list         args;
+    size_t          length;             // complete string length (sans \0)
+    size_t          oldLength;          // original string length (sans \0)
+    ssize_t         tailLength;         // length of string to append
+
+    if (!*dest) {
+        *dest = psStringCopy("");
+        oldLength = 0;
+    } else {
+        // size of existing string
+        oldLength = strlen(*dest);
+    }
+
+    // find the size of the string to append
+    va_start(args, format);
+    // C99 guarentees vsnprintf() to work as expected with size = 0
+    tailLength = vsnprintf(*dest, 0, format, args);
+    va_end(args);
+
+    // if the new tail is zero length, return the length of the old string.  if
+    // it's a format error, return the error code.
+    if (tailLength < 1) {
+        return tailLength == 0 ? oldLength : tailLength;
+    }
+
+    // new string length (sans \0)
+    length = oldLength + tailLength;
+
+    // realloc string to string + tail + \0
+    *dest = psRealloc(*dest, length + 1);
+
+    // append tail + \0
+    va_start(args, format);
+    vsnprintf(*dest + oldLength, tailLength + 1, format, args);
+    va_end(args);
+
+    return length;
+}
+
+ssize_t psStringPrepend(char **dest, const char *format, ...)
+{
+    va_list         args;
+    size_t          length;             // complete string length (sans \0)
+    ssize_t         headLength;         // length of string to prepend
+    char            *oldDest;           // copy of original string
+
+    if (!*dest) {
+        // makes the string backup and concatination pointless
+        *dest = psStringCopy("");
+        length = 0;
+    } else {
+        // size of existing string
+        length = strlen(*dest);
+    }
+
+    // find the size of the string to prepend
+    va_start(args, format);
+    // C99 guarentees vsnprintf() to work as expected with size = 0
+    headLength = vsnprintf(*dest, 0, format, args);
+    va_end(args);
+
+    // if the new head is zero length, return the length of the old string.  if
+    // it's a format error, return the error code.
+    if (headLength < 1) {
+        return headLength == 0 ? length : headLength;
+    }
+
+    // backup original string
+    oldDest = psStringCopy(*dest);
+
+    // new string length (sans \0)
+    length += headLength;
+
+    // realloc string to head + string + \0
+    *dest = psRealloc(*dest, length + 1);
+
+    // copy the new head to the beginning of string
+    va_start(args, format);
+    vsnprintf(*dest, length + 1, format, args);
+    va_end(args);
+
+    // append the original string
+    strncat(*dest, oldDest, length + 1);
+
+    psFree(oldDest);
+
+    return length;
+}
Index: pslib/src/sysUtils/psString.h
diff -u pslib/src/sysUtils/psString.h:1.1 pslib/src/sysUtils/psString.h:1.2
--- pslib/src/sysUtils/psString.h:1.1	Thu Feb 17 09:26:24 2005
+++ pslib/src/sysUtils/psString.h	Thu May  5 14:42:27 2005
@@ -9,8 +9,8 @@
  *
  *  @author Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name:  $
- *  @date $Date: 2005/02/17 19:26:24 $
+ *  @version $Revision: 1.2 $ $Name:  $
+ *  @date $Date: 2005/05/06 00:42:27 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -18,6 +18,7 @@
 #ifndef PS_STRING_H
 #define PS_STRING_H
 
+#include <sys/types.h>
 #include "psType.h"
 
 /** This macro will convert the argument to a quoted string */
@@ -66,6 +67,34 @@
     /**< Number of bytes to allocate for string copy */
 );
 
+/** Appends a format onto a string
+ *
+ * This function shall allocate a new string if dest is NULL.  dest shall be
+ * automatically extended to the size of the new string.
+ *
+ * @return The length of the new string (excluding '\0')
+ */
+
+ssize_t psStringAppend(
+    char **dest,                        ///< existing string
+    const char *format,                 ///< format to append
+    ...                                 ///< format arguments
+);
+
+/** Prepends a format onto a string
+ *
+ * This function shall allocate a new string if dest is NULL.  dest shall be
+ * automatically extended to the size of the new string.
+ *
+ * @return The length of the new string (excluding '\0')
+ */
+
+ssize_t psStringPrepend(
+    char **dest,                        ///< existing string
+    const char *format,                 ///< format to append
+    ...                                 ///< format arguments
+);
+
 /* @} */// Doxygen - End of SystemGroup Functions
 
 #endif
