summaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-09 01:48:34 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-09 01:48:34 +0200
commit2b2da0beab8dc24c79b94b40fed2f9bf08999d82 (patch)
tree6ff6128ed5fa4c2188d88ed0e2528b5372fadc2c /common.c
parentf57cc7923db6698fb7bb7a906da52cf3b952a15c (diff)
downloadxK-2b2da0beab8dc24c79b94b40fed2f9bf08999d82.tar.gz
xK-2b2da0beab8dc24c79b94b40fed2f9bf08999d82.tar.xz
xK-2b2da0beab8dc24c79b94b40fed2f9bf08999d82.zip
degesch: support CASEMAPPING=rfc1459-strict
Diffstat (limited to 'common.c')
-rw-r--r--common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/common.c b/common.c
index 12e1eff..62efb6f 100644
--- a/common.c
+++ b/common.c
@@ -58,6 +58,16 @@
(link)->next = (following); \
BLOCK_END
+#define TRIVIAL_STRXFRM(name, fn) \
+ static size_t \
+ name (char *dest, const char *src, size_t n) \
+ { \
+ size_t len = strlen (src); \
+ while (n-- && (*dest++ = (fn) (*src++))) \
+ ; \
+ return len; \
+ }
+
static void
transform_str (char *s, int (*tolower) (int c))
{
@@ -103,6 +113,17 @@ strncasecmp_ascii (const char *a, const char *b, size_t n)
return 0;
}
+static int
+irc_tolower_strict (int c)
+{
+ if (c == '[') return '{';
+ if (c == ']') return '}';
+ if (c == '\\') return '|';
+ return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c;
+}
+
+TRIVIAL_STRXFRM (irc_strxfrm_strict, irc_tolower_strict)
+
static char *
resolve_relative_runtime_filename (const char *filename)
{