Changeset 3866
- Timestamp:
- May 6, 2005, 8:15:25 AM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 8 edited
-
pslib.kdevelop.pcs (modified) ( previous)
-
pslib.kdevses (modified) (1 diff)
-
src/dataIO/psDB.c (modified) (3 diffs)
-
src/db/psDB.c (modified) (3 diffs)
-
src/sys/psString.c (modified) (2 diffs)
-
src/sys/psString.h (modified) (3 diffs)
-
src/sysUtils/psString.c (modified) (2 diffs)
-
src/sysUtils/psString.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/pslib.kdevses
r3779 r3866 2 2 <!DOCTYPE KDevPrjSession> 3 3 <KDevPrjSession> 4 <DocsAndViews NumberOfDocuments="0" /> 4 <DocsAndViews NumberOfDocuments="6" > 5 <Doc0 NumberOfViews="1" URL="file:///home/desonia/panstarrs/psLib/src/dataIO/psFits.c" > 6 <View0 line="1202" Type="Source" /> 7 </Doc0> 8 <Doc1 NumberOfViews="1" URL="file:///home/desonia/panstarrs/psLib/test/image/tst_psImage.c" > 9 <View0 line="35" Type="Source" /> 10 </Doc1> 11 <Doc2 NumberOfViews="1" URL="file:///home/desonia/panstarrs/psLib/configure.ac" > 12 <View0 line="26" Type="Source" /> 13 </Doc2> 14 <Doc3 NumberOfViews="1" URL="file:///home/desonia/panstarrs/psLib/src/sysUtils/psTrace.h" > 15 <View0 line="87" Type="Source" /> 16 </Doc3> 17 <Doc4 NumberOfViews="1" URL="file:///home/desonia/panstarrs/psLib/src/sysUtils/psTrace.c" > 18 <View0 line="522" Type="Source" /> 19 </Doc4> 20 <Doc5 NumberOfViews="1" URL="file:///home/desonia/panstarrs/psLib/src/collections/psMetadata.h" > 21 <View0 line="65" Type="Source" /> 22 </Doc5> 23 </DocsAndViews> 5 24 <pluginList> 6 25 <kdevdebugger> -
trunk/psLib/src/dataIO/psDB.c
r3849 r3866 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-05-0 5 21:11:39$14 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-05-06 18:15:25 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 83 83 // string utility functions 84 84 static char *psDBIntToString(psU64 n); 85 static ssize_t psStringAppend(char **dest, const char *format, ...);86 static ssize_t psStringPrepend(char **dest, const char *format, ...);87 85 88 86 … … 1596 1594 } 1597 1595 1598 static ssize_t psStringAppend(char **dest, const char *format, ...)1599 {1600 va_list args;1601 size_t length; // complete string length (sans \0)1602 size_t oldLength; // original string length (sans \0)1603 ssize_t tailLength; // length of string to append1604 1605 if (!*dest) {1606 *dest = psStringCopy("");1607 oldLength = 0;1608 } else {1609 // size of existing string1610 oldLength = strlen(*dest);1611 }1612 1613 // find the size of the string to append1614 va_start(args, format);1615 // C99 guarentees vsnprintf() to work as expected with size = 01616 tailLength = vsnprintf(*dest, 0, format, args);1617 va_end(args);1618 1619 // if the new tail is zero length, return the length of the old string. if1620 // it's a format error, return the error code.1621 if (tailLength < 1) {1622 return tailLength == 0 ? oldLength : tailLength;1623 }1624 1625 // new string length (sans \0)1626 length = oldLength + tailLength;1627 1628 // realloc string to string + tail + \01629 *dest = psRealloc(*dest, length + 1);1630 1631 // append tail + \01632 va_start(args, format);1633 vsnprintf(*dest + oldLength, tailLength + 1, format, args);1634 va_end(args);1635 1636 return length;1637 }1638 1639 static ssize_t psStringPrepend(char **dest, const char *format, ...)1640 {1641 va_list args;1642 size_t length; // complete string length (sans \0)1643 ssize_t headLength; // length of string to prepend1644 char *oldDest; // copy of original string1645 1646 if (!*dest) {1647 // makes the string backup and concatination pointless1648 *dest = psStringCopy("");1649 length = 0;1650 } else {1651 // size of existing string1652 length = strlen(*dest);1653 }1654 1655 // find the size of the string to prepend1656 va_start(args, format);1657 // C99 guarentees vsnprintf() to work as expected with size = 01658 headLength = vsnprintf(*dest, 0, format, args);1659 va_end(args);1660 1661 // if the new head is zero length, return the length of the old string. if1662 // it's a format error, return the error code.1663 if (headLength < 1) {1664 return headLength == 0 ? length : headLength;1665 }1666 1667 // backup original string1668 oldDest = psStringCopy(*dest);1669 1670 // new string length (sans \0)1671 length += headLength;1672 1673 // realloc string to head + string + \01674 *dest = psRealloc(*dest, length + 1);1675 1676 // copy the new head to the beginning of string1677 va_start(args, format);1678 vsnprintf(*dest, length + 1, format, args);1679 va_end(args);1680 1681 // append the original string1682 strncat(*dest, oldDest, length + 1);1683 1684 psFree(oldDest);1685 1686 return length;1687 }1688 1689 1596 #endif // BUILD_PSDB -
trunk/psLib/src/db/psDB.c
r3849 r3866 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-05-0 5 21:11:39$14 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-05-06 18:15:25 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 83 83 // string utility functions 84 84 static char *psDBIntToString(psU64 n); 85 static ssize_t psStringAppend(char **dest, const char *format, ...);86 static ssize_t psStringPrepend(char **dest, const char *format, ...);87 85 88 86 … … 1596 1594 } 1597 1595 1598 static ssize_t psStringAppend(char **dest, const char *format, ...)1599 {1600 va_list args;1601 size_t length; // complete string length (sans \0)1602 size_t oldLength; // original string length (sans \0)1603 ssize_t tailLength; // length of string to append1604 1605 if (!*dest) {1606 *dest = psStringCopy("");1607 oldLength = 0;1608 } else {1609 // size of existing string1610 oldLength = strlen(*dest);1611 }1612 1613 // find the size of the string to append1614 va_start(args, format);1615 // C99 guarentees vsnprintf() to work as expected with size = 01616 tailLength = vsnprintf(*dest, 0, format, args);1617 va_end(args);1618 1619 // if the new tail is zero length, return the length of the old string. if1620 // it's a format error, return the error code.1621 if (tailLength < 1) {1622 return tailLength == 0 ? oldLength : tailLength;1623 }1624 1625 // new string length (sans \0)1626 length = oldLength + tailLength;1627 1628 // realloc string to string + tail + \01629 *dest = psRealloc(*dest, length + 1);1630 1631 // append tail + \01632 va_start(args, format);1633 vsnprintf(*dest + oldLength, tailLength + 1, format, args);1634 va_end(args);1635 1636 return length;1637 }1638 1639 static ssize_t psStringPrepend(char **dest, const char *format, ...)1640 {1641 va_list args;1642 size_t length; // complete string length (sans \0)1643 ssize_t headLength; // length of string to prepend1644 char *oldDest; // copy of original string1645 1646 if (!*dest) {1647 // makes the string backup and concatination pointless1648 *dest = psStringCopy("");1649 length = 0;1650 } else {1651 // size of existing string1652 length = strlen(*dest);1653 }1654 1655 // find the size of the string to prepend1656 va_start(args, format);1657 // C99 guarentees vsnprintf() to work as expected with size = 01658 headLength = vsnprintf(*dest, 0, format, args);1659 va_end(args);1660 1661 // if the new head is zero length, return the length of the old string. if1662 // it's a format error, return the error code.1663 if (headLength < 1) {1664 return headLength == 0 ? length : headLength;1665 }1666 1667 // backup original string1668 oldDest = psStringCopy(*dest);1669 1670 // new string length (sans \0)1671 length += headLength;1672 1673 // realloc string to head + string + \01674 *dest = psRealloc(*dest, length + 1);1675 1676 // copy the new head to the beginning of string1677 va_start(args, format);1678 vsnprintf(*dest, length + 1, format, args);1679 va_end(args);1680 1681 // append the original string1682 strncat(*dest, oldDest, length + 1);1683 1684 psFree(oldDest);1685 1686 return length;1687 }1688 1689 1596 #endif // BUILD_PSDB -
trunk/psLib/src/sys/psString.c
r3264 r3866 9 9 * @author Eric Van Alst, MHPCC 10 10 * 11 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 2-17 19:26:24$11 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-05-06 18:15:25 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 55 55 return returnValue; 56 56 } 57 58 ssize_t psStringAppend(char **dest, const char *format, ...) 59 { 60 va_list args; 61 size_t length; // complete string length (sans \0) 62 size_t oldLength; // original string length (sans \0) 63 ssize_t tailLength; // length of string to append 64 65 if (!*dest) { 66 *dest = psStringCopy(""); 67 oldLength = 0; 68 } else { 69 // size of existing string 70 oldLength = strlen(*dest); 71 } 72 73 // find the size of the string to append 74 va_start(args, format); 75 // C99 guarentees vsnprintf() to work as expected with size = 0 76 tailLength = vsnprintf(*dest, 0, format, args); 77 va_end(args); 78 79 // if the new tail is zero length, return the length of the old string. if 80 // it's a format error, return the error code. 81 if (tailLength < 1) { 82 return tailLength == 0 ? oldLength : tailLength; 83 } 84 85 // new string length (sans \0) 86 length = oldLength + tailLength; 87 88 // realloc string to string + tail + \0 89 *dest = psRealloc(*dest, length + 1); 90 91 // append tail + \0 92 va_start(args, format); 93 vsnprintf(*dest + oldLength, tailLength + 1, format, args); 94 va_end(args); 95 96 return length; 97 } 98 99 ssize_t psStringPrepend(char **dest, const char *format, ...) 100 { 101 va_list args; 102 size_t length; // complete string length (sans \0) 103 ssize_t headLength; // length of string to prepend 104 char *oldDest; // copy of original string 105 106 if (!*dest) { 107 // makes the string backup and concatination pointless 108 *dest = psStringCopy(""); 109 length = 0; 110 } else { 111 // size of existing string 112 length = strlen(*dest); 113 } 114 115 // find the size of the string to prepend 116 va_start(args, format); 117 // C99 guarentees vsnprintf() to work as expected with size = 0 118 headLength = vsnprintf(*dest, 0, format, args); 119 va_end(args); 120 121 // if the new head is zero length, return the length of the old string. if 122 // it's a format error, return the error code. 123 if (headLength < 1) { 124 return headLength == 0 ? length : headLength; 125 } 126 127 // backup original string 128 oldDest = psStringCopy(*dest); 129 130 // new string length (sans \0) 131 length += headLength; 132 133 // realloc string to head + string + \0 134 *dest = psRealloc(*dest, length + 1); 135 136 // copy the new head to the beginning of string 137 va_start(args, format); 138 vsnprintf(*dest, length + 1, format, args); 139 va_end(args); 140 141 // append the original string 142 strncat(*dest, oldDest, length + 1); 143 144 psFree(oldDest); 145 146 return length; 147 } -
trunk/psLib/src/sys/psString.h
r3264 r3866 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 2-17 19:26:24$12 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-05-06 18:15:25 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 19 19 #define PS_STRING_H 20 20 21 #include <sys/types.h> 21 22 #include "psType.h" 22 23 … … 67 68 ); 68 69 70 /** Appends a format onto a string 71 * 72 * This function shall allocate a new string if dest is NULL. dest shall be 73 * automatically extended to the size of the new string. 74 * 75 * @return The length of the new string (excluding '\0') 76 */ 77 78 ssize_t psStringAppend( 79 char **dest, ///< existing string 80 const char *format, ///< format to append 81 ... ///< format arguments 82 ); 83 84 /** Prepends a format onto a string 85 * 86 * This function shall allocate a new string if dest is NULL. dest shall be 87 * automatically extended to the size of the new string. 88 * 89 * @return The length of the new string (excluding '\0') 90 */ 91 92 ssize_t psStringPrepend( 93 char **dest, ///< existing string 94 const char *format, ///< format to append 95 ... ///< format arguments 96 ); 97 69 98 /* @} */// Doxygen - End of SystemGroup Functions 70 99 -
trunk/psLib/src/sysUtils/psString.c
r3264 r3866 9 9 * @author Eric Van Alst, MHPCC 10 10 * 11 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 2-17 19:26:24$11 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-05-06 18:15:25 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 55 55 return returnValue; 56 56 } 57 58 ssize_t psStringAppend(char **dest, const char *format, ...) 59 { 60 va_list args; 61 size_t length; // complete string length (sans \0) 62 size_t oldLength; // original string length (sans \0) 63 ssize_t tailLength; // length of string to append 64 65 if (!*dest) { 66 *dest = psStringCopy(""); 67 oldLength = 0; 68 } else { 69 // size of existing string 70 oldLength = strlen(*dest); 71 } 72 73 // find the size of the string to append 74 va_start(args, format); 75 // C99 guarentees vsnprintf() to work as expected with size = 0 76 tailLength = vsnprintf(*dest, 0, format, args); 77 va_end(args); 78 79 // if the new tail is zero length, return the length of the old string. if 80 // it's a format error, return the error code. 81 if (tailLength < 1) { 82 return tailLength == 0 ? oldLength : tailLength; 83 } 84 85 // new string length (sans \0) 86 length = oldLength + tailLength; 87 88 // realloc string to string + tail + \0 89 *dest = psRealloc(*dest, length + 1); 90 91 // append tail + \0 92 va_start(args, format); 93 vsnprintf(*dest + oldLength, tailLength + 1, format, args); 94 va_end(args); 95 96 return length; 97 } 98 99 ssize_t psStringPrepend(char **dest, const char *format, ...) 100 { 101 va_list args; 102 size_t length; // complete string length (sans \0) 103 ssize_t headLength; // length of string to prepend 104 char *oldDest; // copy of original string 105 106 if (!*dest) { 107 // makes the string backup and concatination pointless 108 *dest = psStringCopy(""); 109 length = 0; 110 } else { 111 // size of existing string 112 length = strlen(*dest); 113 } 114 115 // find the size of the string to prepend 116 va_start(args, format); 117 // C99 guarentees vsnprintf() to work as expected with size = 0 118 headLength = vsnprintf(*dest, 0, format, args); 119 va_end(args); 120 121 // if the new head is zero length, return the length of the old string. if 122 // it's a format error, return the error code. 123 if (headLength < 1) { 124 return headLength == 0 ? length : headLength; 125 } 126 127 // backup original string 128 oldDest = psStringCopy(*dest); 129 130 // new string length (sans \0) 131 length += headLength; 132 133 // realloc string to head + string + \0 134 *dest = psRealloc(*dest, length + 1); 135 136 // copy the new head to the beginning of string 137 va_start(args, format); 138 vsnprintf(*dest, length + 1, format, args); 139 va_end(args); 140 141 // append the original string 142 strncat(*dest, oldDest, length + 1); 143 144 psFree(oldDest); 145 146 return length; 147 } -
trunk/psLib/src/sysUtils/psString.h
r3264 r3866 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 2-17 19:26:24$12 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-05-06 18:15:25 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 19 19 #define PS_STRING_H 20 20 21 #include <sys/types.h> 21 22 #include "psType.h" 22 23 … … 67 68 ); 68 69 70 /** Appends a format onto a string 71 * 72 * This function shall allocate a new string if dest is NULL. dest shall be 73 * automatically extended to the size of the new string. 74 * 75 * @return The length of the new string (excluding '\0') 76 */ 77 78 ssize_t psStringAppend( 79 char **dest, ///< existing string 80 const char *format, ///< format to append 81 ... ///< format arguments 82 ); 83 84 /** Prepends a format onto a string 85 * 86 * This function shall allocate a new string if dest is NULL. dest shall be 87 * automatically extended to the size of the new string. 88 * 89 * @return The length of the new string (excluding '\0') 90 */ 91 92 ssize_t psStringPrepend( 93 char **dest, ///< existing string 94 const char *format, ///< format to append 95 ... ///< format arguments 96 ); 97 69 98 /* @} */// Doxygen - End of SystemGroup Functions 70 99
Note:
See TracChangeset
for help on using the changeset viewer.
