4 * Copyright 2003-2004 Oliver Feiler <kiza@kcore.de>
8 * Library support functions.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 /******************************************************************************
34 * This is a replacement for strsep which is not portable (missing on Solaris).
36 * http://www.winehq.com/hypermail/wine-patches/2001/11/0024.html
38 * The following function was written by François Gouget.
41 char* strsep(char** str, const char* delims)
52 if (strchr(delims,**str)!=NULL) {
59 /* There is no other token */
65 /* strcasestr stolen from: http://www.unixpapa.com/incnote/string.html */
66 char *s_strcasestr(char *a, char *b) {
72 snprintf(f, sizeof(f), "%c%c", tolower(*b), toupper(*b));
73 for (l = strcspn(a, f); l != lena; l += strcspn(a + l + 1, f) + 1)
74 if (strncasecmp(a + l, b, lenb) == 0)
80 /* Private malloc wrapper. Aborts program execution if malloc fails. */
81 void * s_malloc (size_t size) {
84 newmem = malloc (size);
87 fprintf(stderr, "Error allocating memory: %s\n", strerror(errno));