diff options
author | Martin Willi <martin@revosec.ch> | 2015-04-15 16:05:54 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2015-04-16 14:49:19 +0200 |
commit | bbfe7a80b13f01c41eeda59a5f0b5801ebf73553 (patch) | |
tree | d7c0f00f127a644f3e6fa579866f664bc5c0cce2 /src/libstrongswan/utils/utils.c | |
parent | 03cf888277d44f49bba7180a4badbf890438d9b3 (diff) | |
download | strongswan-bbfe7a80b13f01c41eeda59a5f0b5801ebf73553.tar.bz2 strongswan-bbfe7a80b13f01c41eeda59a5f0b5801ebf73553.tar.xz |
string: Move string related utility functions to separate files
Diffstat (limited to 'src/libstrongswan/utils/utils.c')
-rw-r--r-- | src/libstrongswan/utils/utils.c | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/libstrongswan/utils/utils.c b/src/libstrongswan/utils/utils.c index 8a52d04c5..14eff33e2 100644 --- a/src/libstrongswan/utils/utils.c +++ b/src/libstrongswan/utils/utils.c @@ -215,80 +215,6 @@ void *utils_memrchr(const void *s, int c, size_t n) return NULL; } -/** - * Described in header. - */ -char* translate(char *str, const char *from, const char *to) -{ - char *pos = str; - if (strlen(from) != strlen(to)) - { - return str; - } - while (pos && *pos) - { - char *match; - if ((match = strchr(from, *pos)) != NULL) - { - *pos = to[match - from]; - } - pos++; - } - return str; -} - -/** - * Described in header. - */ -char* strreplace(const char *str, const char *search, const char *replace) -{ - size_t len, slen, rlen, count = 0; - char *res, *pos, *found, *dst; - - if (!str || !*str || !search || !*search || !replace) - { - return (char*)str; - } - slen = strlen(search); - rlen = strlen(replace); - if (slen != rlen) - { - for (pos = (char*)str; (pos = strstr(pos, search)); pos += slen) - { - found = pos; - count++; - } - if (!count) - { - return (char*)str; - } - len = (found - str) + strlen(found) + count * (rlen - slen); - } - else - { - len = strlen(str); - } - found = strstr(str, search); - if (!found) - { - return (char*)str; - } - dst = res = malloc(len + 1); - pos = (char*)str; - do - { - len = found - pos; - memcpy(dst, pos, len); - dst += len; - memcpy(dst, replace, rlen); - dst += rlen; - pos = found + slen; - } - while ((found = strstr(pos, search))); - strcpy(dst, pos); - return res; -} - #ifdef WIN32 /** |