aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-11-16 22:00:29 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-11-16 22:00:29 +0300
commit3ebceeece2204d3755df1f1cc8210f7e97b6daad (patch)
tree38c122341dbbb2f1ea1a4c969ad95dda38c1106e /src/util.h
parentc85dd608a568d61e3b24c55b715ad37ceedb7110 (diff)
downloadrspamd-3ebceeece2204d3755df1f1cc8210f7e97b6daad.tar.gz
rspamd-3ebceeece2204d3755df1f1cc8210f7e97b6daad.zip
Make own strlcpy that does not calculate remaining string length (faster and more safe)
Allow only ASCII symbols in logs, escape control chars
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index f5ce840be..36d650877 100644
--- a/src/util.h
+++ b/src/util.h
@@ -108,6 +108,7 @@ void g_ptr_array_unref (GPtrArray *array);
* %p void *
* %V f_str_t *
* %s null-terminated string
+ * %S ascii null-terminated string
* %*s length and string
* %Z '\0'
* %N '\n'
@@ -120,4 +121,26 @@ gint rspamd_fprintf (FILE *f, const gchar *fmt, ...);
gint rspamd_snprintf (gchar *buf, size_t max, const gchar *fmt, ...);
gchar *rspamd_vsnprintf (gchar *buf, size_t max, const gchar *fmt, va_list args);
+/*
+ * Copy src to dest limited to len, in compare with standart strlcpy(3) rspamd strlcpy does not
+ * traverse the whole string and it is possible to use it for non NULL terminated strings. This is
+ * more like memccpy(dst, src, size, '\0')
+ *
+ * @param dst destination string
+ * @param src source string
+ * @param siz length of destination buffer
+ * @return bytes copied
+ */
+gsize rspamd_strlcpy (gchar *dst, const gchar *src, gsize siz);
+
+/*
+ * Escape rspamd string to write it to log file or other 7 bit prefferable places
+ *
+ * @param dst destination string
+ * @param src source string
+ * @param len length of destination buffer
+ * @return pointer to end of buffer
+ */
+gchar * rspamd_escape_string (gchar *dst, const gchar *src, gsize len);
+
#endif