OpenVPN
compat-strsep.c
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single UDP port, with support for SSL/TLS-based
4  * session authentication and key exchange,
5  * packet encryption, packet authentication, and
6  * packet compression.
7  *
8  * Copyright (C) 2019-2022 Arne Schwabe <arne@rfc2549.org>
9  * Copyright (C) 1992-2019 Free Software Foundation, Inc.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2
13  * as published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #elif defined(_MSC_VER)
28 #include "config-msvc.h"
29 #endif
30 
31 #ifndef HAVE_STRSEP
32 #include <string.h>
33 
34 /*
35  * Modified version based on the glibc
36  */
37 char *
38 strsep(char **stringp, const char *delim)
39 {
40  char *begin, *end;
41  begin = *stringp;
42  if (begin == NULL)
43  {
44  return NULL;
45  }
46  /* Find the end of the token. */
47  end = begin + strcspn(begin, delim);
48  if (*end)
49  {
50  /* Terminate the token and set *STRINGP past NUL character. */
51  *end++ = '\0';
52  *stringp = end;
53  }
54  else
55  {
56  /* No more delimiters; this is the last token. */
57  *stringp = NULL;
58  }
59  return begin;
60 }
61 #endif /* ifndef HAVE_STRSEP */
config-msvc.h
strsep
char * strsep(char **stringp, const char *delim)
Definition: compat-strsep.c:38
config.h