diff options
author | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2001-05-24 15:22:37 +0000 |
---|---|---|
committer | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2001-05-24 15:22:37 +0000 |
commit | 46dd11fbb66a9b7647a09239b99f3b914b4bad8a (patch) | |
tree | 1c56c89fc02bffe6657c4802d60145f8b9f3d954 /src/include/util_String.h | |
parent | 051b4e81e2296d3c02836aee3ec815309a037f70 (diff) |
Added Util_asprintf,Util_asnprintf,Util_snprintf,Util_vsnprintf.
asprintf is like sprintf, but the first arg is a char ** and should basically be
the address of a null pointer. The routine allocates enough space and passes back
the new buffer pointer.
asnprintf is as above, but the buffer need not be null. The thirs argument is the
size of the current buffer, and if the string would be larger than that, the current
buffer is freed and a new buffer big enough is allocated.
snprintf and vsnprintf are pretty standard, except we don't have them on all platforms
so I hunted down a file on the internet, written by Patrick Powel (papowell@astart.com),
to give us a portable version of the functionality. It may not be entirely up to
scratch with floating point - I've not tested it too thouroughly yet.
This should enable us to make the web-server stuff a bit more secure against buffer-overruns.
Tom
git-svn-id: http://svn.cactuscode.org/flesh/trunk@2209 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/include/util_String.h')
-rw-r--r-- | src/include/util_String.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/include/util_String.h b/src/include/util_String.h index 2dab9a7d..1496b89c 100644 --- a/src/include/util_String.h +++ b/src/include/util_String.h @@ -5,9 +5,11 @@ @desc String routines @enddesc - @version $History$ + @version $Header$ @@*/ +#include <stdarg.h> + #ifndef _UTIL_STRING_H_ #define _UTIL_STRING_H_ 1 @@ -33,6 +35,12 @@ char *Util_Strdup(const char *s); int Util_StrCmpi(const char *string1, const char *string2); +int Util_vsnprintf (char *str, size_t count, const char *fmt, va_list args); +int Util_snprintf (char *str,size_t count,const char *fmt,...); + +int Util_asprintf(char **buffer, const char *fmt, ...); +int Util_asnprintf(char **buffer, size_t size, const char *fmt, ...); + #ifdef __cplusplus } #endif |