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-2024 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 #endif
28 
29 #ifndef HAVE_STRSEP
30 #include <string.h>
31 
32 /*
33  * Modified version based on the glibc
34  */
35 char *
36 strsep(char **stringp, const char *delim)
37 {
38  char *begin, *end;
39  begin = *stringp;
40  if (begin == NULL)
41  {
42  return NULL;
43  }
44  /* Find the end of the token. */
45  end = begin + strcspn(begin, delim);
46  if (*end)
47  {
48  /* Terminate the token and set *STRINGP past NUL character. */
49  *end++ = '\0';
50  *stringp = end;
51  }
52  else
53  {
54  /* No more delimiters; this is the last token. */
55  *stringp = NULL;
56  }
57  return begin;
58 }
59 #endif /* ifndef HAVE_STRSEP */
strsep
char * strsep(char **stringp, const char *delim)
Definition: compat-strsep.c:36
config.h