add some useful things

This commit is contained in:
Ian 2022-11-27 19:33:07 -05:00
parent bdc677fc97
commit dc2cbdf1be
2 changed files with 21 additions and 0 deletions

View file

@ -132,6 +132,25 @@ void InsertLinkAfter (link_t *l, link_t *after)
============================================================================
*/
#define snprintf_func snprintf
#define vsnprintf_func vsnprintf
int q_vsnprintf(char *str, size_t size, const char *format, va_list args)
{
int ret;
ret = vsnprintf_func (str, size, format, args);
if (ret < 0)
ret = (int)size;
if (size == 0) /* no buffer */
return ret;
if ((size_t)ret >= size)
str[size - 1] = '\0';
return ret;
}
int q_snprintf (char *str, size_t size, const char *format, ...)
{
int ret;

View file

@ -155,6 +155,8 @@ int Q_strcasecmp (char *s1, char *s2);
int Q_strncasecmp (char *s1, char *s2, int n);
int Q_atoi (char *str);
float Q_atof (char *str);
int q_snprintf (char *str, size_t size, const char *format, ...);
int q_vsnprintf(char *str, size_t size, const char *format, va_list args);
//============================================================================