]> git.ipfire.org Git - thirdparty/squid.git/blame - compat/strsep.c
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / compat / strsep.c
CommitLineData
1cd53467 1/* Copyright (C) 2004 Free Software Foundation, Inc.
2 * Written by Yoann Vandoorselaere <yoann@prelude-ids.org>
3 *
4 * The file is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This file is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this file; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 * USA.
18 */
19
f7f3304a 20#include "squid.h"
27bc2077 21#include "compat/strsep.h"
1cd53467 22
23#include <string.h>
24
25char *
27bc2077 26strsep(char **stringp, const char *delim)
1cd53467 27{
26ac0430
AJ
28 char *start = *stringp;
29 char *ptr;
30
31 if (!start)
32 return NULL;
33
34 if (!*delim)
35 ptr = start + strlen (start);
36 else {
37 ptr = strpbrk (start, delim);
38 if (!ptr) {
39 *stringp = NULL;
40 return start;
41 }
1cd53467 42 }
43
26ac0430
AJ
44 *ptr = '\0';
45 *stringp = ptr + 1;
1cd53467 46
26ac0430 47 return start;
1cd53467 48}