1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Authors: Jeffrey Stedfast <fejj@ximian.com>
5 * Copyright 2002 Ximian, Inc. (www.ximian.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
31 #include "string-utils.h"
35 g_strcase_equal (gconstpointer a, gconstpointer b)
37 return (strcasecmp ((const char *) a, (const char *) b) == 0);
41 g_strcase_hash (gconstpointer v)
43 const char *p = (char *) v;
46 for ( ; *p != '\0'; p++) {
47 h = (h << 4) + toupper (*p);
48 if ((g = h & 0xf0000000)) {
59 free_string (gpointer string, gpointer user_data)
65 string_list_free (GList *string_list)
67 if (string_list == NULL)
70 g_list_foreach (string_list, free_string, NULL);
71 g_list_free (string_list);
75 camel_strstrcase (const char *haystack, const char *needle)
77 /* find the needle in the haystack neglecting case */
81 g_return_val_if_fail (haystack != NULL, NULL);
82 g_return_val_if_fail (needle != NULL, NULL);
84 len = strlen (needle);
85 if (len > strlen (haystack))
89 return (char *) haystack;
91 for (ptr = haystack; *(ptr + len - 1) != '\0'; ptr++)
92 if (!strncasecmp (ptr, needle, len))
100 camel_strdown (char *str)
102 register char *s = str;
105 if (*s >= 'A' && *s <= 'Z')