From adaf410d37f9373399c7b6df648ea3def666eaa4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 4 Feb 2006 23:45:20 +0000 Subject: [PATCH] inlined code --- src/common/util/strings.c | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/common/util/strings.c diff --git a/src/common/util/strings.c b/src/common/util/strings.c new file mode 100644 index 000000000..fa724ac53 --- /dev/null +++ b/src/common/util/strings.c @@ -0,0 +1,58 @@ +/* vi: set ts=2: + * + * + * Eressea PB(E)M host Copyright (C) 1998-2003 + * Christian Schlittchen (corwin@amber.kn-bremen.de) + * Katja Zedel (katze@felidae.kn-bremen.de) + * Henning Peters (faroul@beyond.kn-bremen.de) + * Enno Rehling (enno@eressea-pbem.de) + * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) + * + * based on: + * + * Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace + * Atlantis v1.7 Copyright 1996 by Alex Schröder + * + * This program may not be used, modified or distributed without + * prior permission by the authors of Eressea. + * This program may not be sold or used commercially without prior written + * permission from the authors. + */ + +#include + +/* libc includes */ +#include + +INLINE_FUNCTION unsigned int +hashstring(const char* s) +{ + unsigned int key = 0; + while (*s) { + key = key*37 + *s++; + } + return key & 0x7FFFFFFF; +} + +INLINE_FUNCTION const char * +escape_string(const char * str, char * buffer, unsigned int len) +{ + static char s_buffer[4096]; + const char * p = str; + char * o; + if (buffer==NULL) { + buffer = s_buffer; + len = sizeof(s_buffer); + } + o = buffer; + do { + switch (*p) { + case '\"': + case '\\': + (*o++) = '\\'; + } + (*o++) = (*p); + } while (*p++); + return buffer; +} +