summaryrefslogtreecommitdiffstats
path: root/src/openvpn
diff options
context:
space:
mode:
authorAlon Bar-Lev <alon.barlev@gmail.com>2012-02-29 22:12:14 +0200
committerDavid Sommerseth <davids@redhat.com>2012-03-22 22:53:39 +0100
commitdc81e743989640cc681a40e69455cc9fc736ab9c (patch)
treef6706bec7d6e104693836be58f92da0a99f3bc50 /src/openvpn
parentc110b289eced4a792fd7c7c29e651b22f602fd24 (diff)
downloadopenvpn-dc81e743989640cc681a40e69455cc9fc736ab9c.tar.gz
openvpn-dc81e743989640cc681a40e69455cc9fc736ab9c.tar.xz
openvpn-dc81e743989640cc681a40e69455cc9fc736ab9c.zip
build: split out compat
compat should not use any of the main project headers or conventions, it should be a standalone library that provides missing library functions. Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com> Acked-by: David Sommerseth <davids@redhat.com> Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'src/openvpn')
-rw-r--r--src/openvpn/Makefile.am6
-rw-r--r--src/openvpn/compat.c135
-rw-r--r--src/openvpn/compat.h40
-rw-r--r--src/openvpn/openvpn.vcproj12
-rw-r--r--src/openvpn/syshead.h4
5 files changed, 10 insertions, 187 deletions
diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
index 3d8c0a9..e170380 100644
--- a/src/openvpn/Makefile.am
+++ b/src/openvpn/Makefile.am
@@ -17,7 +17,9 @@ MAINTAINERCLEANFILES = \
EXTRA_DIST = \
openvpn.vcproj
-INCLUDES = -I$(top_srcdir)/include
+INCLUDES = \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src/compat
AM_CFLAGS = \
$(OPTIONAL_CRYPTO_CFLAGS) \
@@ -33,7 +35,6 @@ openvpn_SOURCES = \
circ_list.h \
clinat.c clinat.h \
common.h \
- compat.h compat.c \
crypto.c crypto.h crypto_backend.h \
crypto_openssl.c crypto_openssl.h \
crypto_polarssl.c crypto_polarssl.h \
@@ -104,6 +105,7 @@ openvpn_SOURCES = \
win32.h win32.c \
cryptoapi.h cryptoapi.c
openvpn_LDADD = \
+ $(top_builddir)/src/compat/libcompat.la \
$(SOCKETS_LIBS) \
$(OPTIONAL_LZO_LIBS) \
$(OPTIONAL_PKCS11_HELPER_LIBS) \
diff --git a/src/openvpn/compat.c b/src/openvpn/compat.c
deleted file mode 100644
index f2fa265..0000000
--- a/src/openvpn/compat.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * OpenVPN -- An application to securely tunnel IP networks
- * over a single UDP port, with support for SSL/TLS-based
- * session authentication and key exchange,
- * packet encryption, packet authentication, and
- * packet compression.
- *
- * Copyright (C) 2011 - David Sommerseth <davids@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program (see the file COPYING included with this
- * distribution); if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#elif defined(_MSC_VER)
-#include "config-msvc.h"
-#endif
-
-#include "syshead.h"
-#include "compat.h"
-#include <string.h>
-
-
-#ifndef HAVE_DIRNAME
-/* Unoptimised version of glibc memrchr().
- * This is considered fast enough, as only this compat
- * version of dirname() depends on it.
- */
-static const char *
-__memrchr(const char *str, int c, size_t n)
-{
- const char *end = str;
-
- end += n - 1; /* Go to the end of the string */
- while (end >= str) {
- if(c == *end)
- return end;
- else
- end--;
- }
- return NULL;
-}
-
-/* Modified version based on glibc-2.14.1 by Ulrich Drepper <drepper@akkadia.org>
- * This version is extended to handle both / and \ in path names.
- */
-char *
-dirname (char *path)
-{
- static const char dot[] = ".";
- char *last_slash;
- char separator = '/';
-
- /* Find last '/'. */
- last_slash = path != NULL ? strrchr (path, '/') : NULL;
- /* If NULL, check for \ instead ... might be Windows a path */
- if (!last_slash) {
- last_slash = path != NULL ? strrchr (path, '\\') : NULL;
- separator = last_slash ? '\\' : '/'; /* Change the separator if \ was found */
- }
-
- if (last_slash != NULL && last_slash != path && last_slash[1] == '\0') {
- /* Determine whether all remaining characters are slashes. */
- char *runp;
-
- for (runp = last_slash; runp != path; --runp)
- if (runp[-1] != separator)
- break;
-
- /* The '/' is the last character, we have to look further. */
- if (runp != path)
- last_slash = (char *) __memrchr (path, separator, runp - path);
- }
-
- if (last_slash != NULL) {
- /* Determine whether all remaining characters are slashes. */
- char *runp;
-
- for (runp = last_slash; runp != path; --runp)
- if (runp[-1] != separator)
- break;
-
- /* Terminate the path. */
- if (runp == path) {
- /* The last slash is the first character in the string. We have to
- return "/". As a special case we have to return "//" if there
- are exactly two slashes at the beginning of the string. See
- XBD 4.10 Path Name Resolution for more information. */
- if (last_slash == path + 1)
- ++last_slash;
- else
- last_slash = path + 1;
- }
- else
- last_slash = runp;
-
- last_slash[0] = '\0';
- } else
- /* This assignment is ill-designed but the XPG specs require to
- return a string containing "." in any case no directory part is
- found and so a static and constant string is required. */
- path = (char *) dot;
-
- return path;
-}
-#endif /* HAVE_DIRNAME */
-
-
-#ifndef HAVE_BASENAME
-/* Modified version based on glibc-2.14.1 by Roland McGrath <roland@gnu.org>
- * This version is extended to handle both / and \ in path names
- */
-char *
-basename (char *filename)
-{
- char *p = strrchr (filename, '/');
- if (!p) {
- /* If NULL, check for \ instead ... might be Windows a path */
- p = strrchr (filename, '\\');
- }
- return p ? p + 1 : (char *) filename;
-}
-#endif /* HAVE_BASENAME */
diff --git a/src/openvpn/compat.h b/src/openvpn/compat.h
deleted file mode 100644
index 7af9fe2..0000000
--- a/src/openvpn/compat.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * OpenVPN -- An application to securely tunnel IP networks
- * over a single UDP port, with support for SSL/TLS-based
- * session authentication and key exchange,
- * packet encryption, packet authentication, and
- * packet compression.
- *
- * Copyright (C) 2011 - David Sommerseth <davids@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program (see the file COPYING included with this
- * distribution); if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef COMPAT_H
-#define COMPAT_H
-
-#if defined(HAVE_BASENAME) || defined(HAVE_DIRNAME)
-#include <libgen.h>
-#endif
-
-#ifndef HAVE_DIRNAME
-char * dirname(char *str);
-#endif /* HAVE_DIRNAME */
-
-#ifndef HAVE_BASENAME
-char * basename(char *str);
-#endif /* HAVE_BASENAME */
-
-#endif /* COMPAT_H */
diff --git a/src/openvpn/openvpn.vcproj b/src/openvpn/openvpn.vcproj
index 8a3f4b0..45c0a77 100644
--- a/src/openvpn/openvpn.vcproj
+++ b/src/openvpn/openvpn.vcproj
@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
+ AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/src/compat;$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;$(CPPFLAGS)"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -118,7 +118,7 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
+ AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/src/compat;$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;$(CPPFLAGS)"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
@@ -191,10 +191,6 @@
>
</File>
<File
- RelativePath=".\compat.c"
- >
- </File>
- <File
RelativePath=".\crypto.c"
>
</File>
@@ -461,10 +457,6 @@
>
</File>
<File
- RelativePath=".\compat.h"
- >
- </File>
- <File
RelativePath=".\crypto.h"
>
</File>
diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h
index f9636f7..e8da88c 100644
--- a/src/openvpn/syshead.h
+++ b/src/openvpn/syshead.h
@@ -181,6 +181,10 @@
#include <selinux/selinux.h>
#endif
+#if defined(HAVE_LIBGEN_H)
+#include <libgen.h>
+#endif
+
#ifdef TARGET_SOLARIS
#ifdef HAVE_STRINGS_H
#include <strings.h>