aboutsummaryrefslogtreecommitdiffstats
path: root/src/printf.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-06-09 17:33:07 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-06-09 17:33:07 +0400
commit25591d79bad7c201ee12717cde3c6c39e39e48e5 (patch)
tree996d5e14b47ee8dd11e826d1c02767f7e513bf1a /src/printf.c
parent8c23f93d02fb111baa27e8141b13d6fe658bb155 (diff)
downloadrspamd-25591d79bad7c201ee12717cde3c6c39e39e48e5.tar.gz
rspamd-25591d79bad7c201ee12717cde3c6c39e39e48e5.zip
* Add api for creating XML-rpc calls
Diffstat (limited to 'src/printf.c')
-rw-r--r--src/printf.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/printf.c b/src/printf.c
index 7bdb61cc3..a8bf0fdb1 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -138,7 +138,7 @@ rspamd_sprintf (gchar *buf, const gchar *fmt, ...)
gint
-rspamd_snprintf (gchar *buf, size_t max, const gchar *fmt, ...)
+rspamd_snprintf (gchar *buf, glong max, const gchar *fmt, ...)
{
gchar *p;
va_list args;
@@ -152,13 +152,17 @@ rspamd_snprintf (gchar *buf, size_t max, const gchar *fmt, ...)
}
gchar *
-rspamd_escape_string (gchar *dst, const gchar *src, gsize len)
+rspamd_escape_string (gchar *dst, const gchar *src, glong len)
{
gchar *buf = dst, *last = dst + len;
guint8 c;
const gchar *p = src;
gunichar uc;
+ if (len <= 0) {
+ return dst;
+ }
+
while (*p && buf < last) {
/* Detect utf8 */
uc = g_utf8_get_char_validated (p, last - buf);
@@ -202,7 +206,7 @@ rspamd_escape_string (gchar *dst, const gchar *src, gsize len)
}
gchar *
-rspamd_vsnprintf (gchar *buf, size_t max, const gchar *fmt, va_list args)
+rspamd_vsnprintf (gchar *buf, glong max, const gchar *fmt, va_list args)
{
gchar *p, zero, *last;
gint d;
@@ -213,7 +217,7 @@ rspamd_vsnprintf (gchar *buf, size_t max, const gchar *fmt, va_list args)
guint width, sign, hex, max_width, frac_width, i;
f_str_t *v;
- if (max == 0) {
+ if (max <= 0) {
return buf;
}