[Openvpn-devel] [PATCH v2] options: Move string utility functions to buffer

Gert Doering <[email protected]>
Newsgroups net.sourceforge.lists.openvpn-devel
Message-ID <[email protected]>
From: Frank Lichtenheld <[email protected]>

buffer seems to be where we collect string utility
functions, so move them out of options.

Change-Id: I09ad0d9baaa7351eecb5aafdb5c6e7b47cf7c909
Signed-off-by: Frank Lichtenheld <[email protected]>
Acked-by: Razvan Cojocaru <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1775
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1775
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <[email protected]>

        
diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c
index 2f4d037..6531f3e 100644
--- a/src/openvpn/buffer.c
+++ b/src/openvpn/buffer.c
@@ -1142,6 +1142,38 @@
 }
 
 bool
+string_defined_equal(const char *s1, const char *s2)
+{
+    if (s1 && s2)
+    {
+        return !strcmp(s1, s2);
+    }
+    else
+    {
+        return false;
+    }
+}
+
+char *
+string_substitute(const char *src, char from, char to, struct gc_arena *gc)
+{
+    char *ret = (char *)gc_malloc(strlen(src) + 1, true, gc);
+    char *dest = ret;
+    char c;
+
+    do
+    {
+        c = *src++;
+        if (c == from)
+        {
+            c = to;
+        }
+        *dest++ = c;
+    } while (c);
+    return ret;
+}
+
+bool
 checked_snprintf(char *str, size_t size, const char *format, ...)
 {
     va_list arglist;
diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h
index 9bdb36a..2776bfc 100644
--- a/src/openvpn/buffer.h
+++ b/src/openvpn/buffer.h
@@ -952,6 +952,9 @@
     return 0 == strncmp(str, prefix, strlen(prefix));
 }
 
+bool string_defined_equal(const char *s1, const char *s2);
+char *string_substitute(const char *src, char from, char to, struct gc_arena *gc);
+
 /**
  * Like snprintf() but returns an boolean.
  *
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 03cda5a..a95b6e0 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -1101,25 +1101,6 @@
     return get_ipv6_addr(ipv6_prefix_spec, NULL, NULL, M_WARN);
 }
 
-static char *
-string_substitute(const char *src, char from, char to, struct gc_arena *gc)
-{
-    char *ret = (char *)gc_malloc(strlen(src) + 1, true, gc);
-    char *dest = ret;
-    char c;
-
-    do
-    {
-        c = *src++;
-        if (c == from)
-        {
-            c = to;
-        }
-        *dest++ = c;
-    } while (c);
-    return ret;
-}
-
 /**
  * Parses a hexstring and checks if the string has the correct length. Return
  * a verify_hash_list containing the parsed hash string.
@@ -3574,19 +3555,6 @@
     }
 }
 
-bool
-string_defined_equal(const char *s1, const char *s2)
-{
-    if (s1 && s2)
-    {
-        return !strcmp(s1, s2);
-    }
-    else
-    {
-        return false;
-    }
-}
-
 #if 0
 static void
 ping_rec_err(msglvl_t msglevel)
diff --git a/src/openvpn/options.h b/src/openvpn/options.h
index d950a67..90a422b 100644
--- a/src/openvpn/options.h
+++ b/src/openvpn/options.h
@@ -896,8 +896,6 @@
 
 void setenv_settings(struct env_set *es, const struct options *o);
 
-bool string_defined_equal(const char *s1, const char *s2);
-
 void options_postprocess(struct options *options, struct env_set *es);
 
 bool options_postprocess_pull(struct options *o, struct env_set *es);


_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.