diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-08-23 02:12:47 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-08-23 02:12:47 +0100 |
commit | a04ed100da7a88bf6a8bf2f1ecb6a77fbb1ed1f8 (patch) | |
tree | 6310dd7d9a0355e99d445af725ececaaea432bce /src/util.c | |
parent | 7d2af49e0f344d78dc68d16f3db318be35430b38 (diff) | |
download | rspamd-a04ed100da7a88bf6a8bf2f1ecb6a77fbb1ed1f8.tar.gz rspamd-a04ed100da7a88bf6a8bf2f1ecb6a77fbb1ed1f8.zip |
Add the tolower variant of strlcpy function.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 90497c803..88d62f974 100644 --- a/src/util.c +++ b/src/util.c @@ -1325,6 +1325,29 @@ rspamd_strlcpy (gchar *dst, const gchar *src, gsize siz) return (s - src - 1); /* count does not include NUL */ } +gsize +rspamd_strlcpy_tolower (gchar *dst, const gchar *src, gsize siz) +{ + gchar *d = dst; + const gchar *s = src; + gsize n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0) { + while (--n != 0) { + if ((*d++ = g_ascii_tolower (*s++)) == '\0') { + break; + } + } + } + + if (n == 0 && siz != 0) { + *d = '\0'; + } + + return (s - src - 1); /* count does not include NUL */ +} + /* Compare two emails for building emails tree */ gint compare_email_func (gconstpointer a, gconstpointer b) |