Add lumiera_tmpbuf_strcat3 for concating up to three strings to safeclib

This commit is contained in:
Christian Thaeter 2008-08-15 17:04:29 +02:00
parent e2b7561c76
commit cfcb9ce34c
2 changed files with 27 additions and 0 deletions

View file

@ -175,6 +175,18 @@ lumiera_tmpbuf_snprintf (size_t size, const char* fmt, ...)
}
char*
lumiera_tmpbuf_strcat3 (const char* str1, size_t str1_len,
const char* str2, size_t str2_len,
const char* str3, size_t str3_len)
{
return lumiera_tmpbuf_snprintf (SIZE_MAX, "%.*s%s%.*s%s%.*s",
str1?str1_len:0, str1?str1:"", str1?".":"",
str2?str2_len:0, str2?str2:"",
str3?".":"", str3?str3_len:0, str3?str3:"");
}
char*
lumiera_tmpbuf_tr (const char* in, const char* from, const char* to, const char* def)
{

View file

@ -135,6 +135,21 @@ lumiera_tmpbuf_strndup (const char* src, size_t size);
char*
lumiera_tmpbuf_snprintf (size_t size, const char* fmt, ...);
/**
* Concat up to 3 strings in a tmpbuf.
* @param str1 first string to concat or NULL
* @param str1_len how much of the first string shall be used
* @param str2 second string to concat or NULL
* @param str2_len how much of the second string shall be used
* @param str3 third string to concat or NULL
* @param str3_len how much of the third string shall be used
* @return temporary buffer containing the constructed of the string
*/
char*
lumiera_tmpbuf_strcat3 (const char* str1, size_t str1_len,
const char* str2, size_t str2_len,
const char* str3, size_t str3_len);
/**
* Translates characters in a string, similar to the shell 'tr' utility
* @param in input string to be translated