aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2010-03-08 15:26:09 +0100
committerTobias Brunner <tobias@strongswan.org>2010-03-08 15:34:38 +0100
commitd543d9cadfd69c01eff883cb2bab927d6a3c1564 (patch)
treee0fcd2a17db2388a0a79dab92a3218fe67d88d66 /src/libstrongswan/utils.c
parentd14203b00954e828883fed0ddcc890d1ff1e02fd (diff)
downloadstrongswan-d543d9cadfd69c01eff883cb2bab927d6a3c1564.tar.bz2
strongswan-d543d9cadfd69c01eff883cb2bab927d6a3c1564.tar.xz
Adding a helper function that translates single characters in a string.
Diffstat (limited to 'src/libstrongswan/utils.c')
-rw-r--r--src/libstrongswan/utils.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libstrongswan/utils.c b/src/libstrongswan/utils.c
index b1b860351..fd313843e 100644
--- a/src/libstrongswan/utils.c
+++ b/src/libstrongswan/utils.c
@@ -119,6 +119,28 @@ void *memstr(const void *haystack, const char *needle, size_t n)
/**
* 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.
+ */
bool mkdir_p(const char *path, mode_t mode)
{
int len;