From patchwork Mon Feb 17 03:43:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1006 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id YKTILdqmSl7/UwAAIUCqbw for ; Mon, 17 Feb 2020 09:44:42 -0500 Received: from proxy6.mail.ord1d.rsapps.net ([172.30.191.6]) by director8.mail.ord1d.rsapps.net with LMTP id IJKxLdqmSl6TGAAAfY0hYg ; Mon, 17 Feb 2020 09:44:42 -0500 Received: from smtp14.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy6.mail.ord1d.rsapps.net with LMTP id GNcGLdqmSl48FwAAQyIf0w ; Mon, 17 Feb 2020 09:44:42 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp14.gate.ord1c.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 07d6233c-5194-11ea-8a85-bc305bf032e0-1-1 Received: from [216.105.38.7] ([216.105.38.7:34508] helo=lists.sourceforge.net) by smtp14.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 13/BE-22403-AD6AA4E5; Mon, 17 Feb 2020 09:44:42 -0500 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1j3hcq-0004SB-SN; Mon, 17 Feb 2020 14:43:56 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1j3hcm-0004Qw-Pk for openvpn-devel@lists.sourceforge.net; Mon, 17 Feb 2020 14:43:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=vl+PMEbnpWUTV4kn1X2mET6OvsVp385p98vrfqnGKgk=; b=e8kba9OFQeUK7D7sZ84vYchebK wAO7qU+rhoA6LcMBCd8py4WKS98z5Mp4ZYtvlpfphiQINhP2rEfFB4nqv0GUXg9Vt1LnEhIiwEAja Y4mtFeqYo2DjBGhQT2XeIfUJ27zb7WX9bO0tUwd/bU2CT5pF2xLV7P38ZxC+PHrg0ldA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=vl+PMEbnpWUTV4kn1X2mET6OvsVp385p98vrfqnGKgk=; b=SkxkmHgsUdcgEAeKZ3i9fjcgS8 tYqcQ9XfDjDZuje0OZwSN0S6mStHn/4k3S12nF6oIbed2m+t+32dKhHoH6RwvgUNJ2ayOoL6pU141 GLc9lYEycuz/8uM7kDvtPyOb83zFYHh7UTY+zoFscuHv5OWQESEsdSGK3jtDpDmU6Bzo=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1j3hcj-006UA6-54 for openvpn-devel@lists.sourceforge.net; Mon, 17 Feb 2020 14:43:52 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1j3hca-0004g7-6q for openvpn-devel@lists.sourceforge.net; Mon, 17 Feb 2020 15:43:40 +0100 Received: (nullmailer pid 3324 invoked by uid 10006); Mon, 17 Feb 2020 14:43:40 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Mon, 17 Feb 2020 15:43:36 +0100 Message-Id: <20200217144339.3273-3-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200217144339.3273-1-arne@rfc2549.org> References: <20200217144339.3273-1-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1j3hcj-006UA6-54 Subject: [Openvpn-devel] [PATCH v4 2/5] Add strsep compat function X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Some operating system do not have the strsep function. Since this API is more "modern" (4.4BSD) than strtok, add it as compat function. Signed-off-by: Arne Schwabe Acked-by: Lev Stipakov --- configure.ac | 2 +- src/compat/Makefile.am | 1 + src/compat/compat-strsep.c | 61 ++++++++++++++++++++++++++++++++++++++ src/compat/compat.h | 4 +++ src/compat/compat.vcxproj | 3 +- 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/compat/compat-strsep.c diff --git a/configure.ac b/configure.ac index 3c057295..a47ef3e7 100644 --- a/configure.ac +++ b/configure.ac @@ -655,7 +655,7 @@ AC_CHECK_FUNCS([ \ ctime memset vsnprintf strdup \ setsid chdir putenv getpeername unlink \ chsize ftruncate execve getpeereid umask basename dirname access \ - epoll_create \ + epoll_create strsep \ ]) AC_CHECK_LIB( diff --git a/src/compat/Makefile.am b/src/compat/Makefile.am index b51f661e..2e94e943 100644 --- a/src/compat/Makefile.am +++ b/src/compat/Makefile.am @@ -30,4 +30,5 @@ libcompat_la_SOURCES = \ compat-inet_ntop.c \ compat-inet_pton.c \ compat-lz4.c compat-lz4.h \ + compat-strsep.c \ compat-versionhelpers.h diff --git a/src/compat/compat-strsep.c b/src/compat/compat-strsep.c new file mode 100644 index 00000000..42ff6414 --- /dev/null +++ b/src/compat/compat-strsep.c @@ -0,0 +1,61 @@ +/* + * 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) 2019 Arne Schwabe + * Copyright (C) 1992-2019 Free Software Foundation, Inc. + * + * 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; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif + +#ifndef HAVE_STRSEP +#include + +/* + * Modified version based on the glibc + */ +char * +strsep(char **stringp, const char *delim) +{ + char *begin, *end; + begin = *stringp; + if (begin == NULL) + { + return NULL; + } + /* Find the end of the token. */ + end = begin + strcspn(begin, delim); + if (*end) + { + /* Terminate the token and set *STRINGP past NUL character. */ + *end++ = '\0'; + *stringp = end; + } + else + { + /* No more delimiters; this is the last token. */ + *stringp = NULL; + } + return begin; +} +#endif diff --git a/src/compat/compat.h b/src/compat/compat.h index d5228989..592881df 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -70,4 +70,8 @@ int inet_pton(int af, const char *src, void *dst); #endif +#ifndef HAVE_STRSEP +char* strsep(char **stringp, const char *delim); +#endif + #endif /* COMPAT_H */ diff --git a/src/compat/compat.vcxproj b/src/compat/compat.vcxproj index e388008a..0c4c7b0f 100644 --- a/src/compat/compat.vcxproj +++ b/src/compat/compat.vcxproj @@ -102,6 +102,7 @@ + @@ -115,4 +116,4 @@ - \ No newline at end of file +