]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/string.c
f60f83008b96c089d5ef5e7928af888573ffba66
2 * "$Id: string.c,v 1.5.2.4 2002/05/09 02:22:09 mike Exp $"
4 * String functions for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2002 by Easy Software Products.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
24 * This file is subject to the Apple OS-Developed Software exception.
28 * ipp_strdup() - Duplicate a string.
29 * ipp_strcasecmp() - Do a case-insensitive comparison.
30 * ipp_strncasecmp() - Do a case-insensitive comparison on up to N chars.
34 * Include necessary headers...
41 * 'ipp_strdup()' - Duplicate a string.
45 char * /* O - New string pointer */
46 ipp_strdup(const char *s
) /* I - String to duplicate */
48 char *t
; /* New string pointer */
54 if ((t
= malloc(strlen(s
) + 1)) == NULL
)
57 return (strcpy(t
, s
));
59 # endif /* !HAVE_STRDUP */
63 * 'ipp_strcasecmp()' - Do a case-insensitive comparison.
66 # ifndef HAVE_STRCASECMP
67 int /* O - Result of comparison (-1, 0, or 1) */
68 ipp_strcasecmp(const char *s
, /* I - First string */
69 const char *t
) /* I - Second string */
71 while (*s
!= '\0' && *t
!= '\0')
73 if (tolower(*s
) < tolower(*t
))
75 else if (tolower(*s
) > tolower(*t
))
82 if (*s
== '\0' && *t
== '\0')
89 # endif /* !HAVE_STRCASECMP */
92 * 'ipp_strncasecmp()' - Do a case-insensitive comparison on up to N chars.
95 # ifndef HAVE_STRNCASECMP
96 int /* O - Result of comparison (-1, 0, or 1) */
97 ipp_strncasecmp(const char *s
, /* I - First string */
98 const char *t
, /* I - Second string */
99 size_t n
) /* I - Maximum number of characters to compare */
101 while (*s
!= '\0' && *t
!= '\0' && n
> 0)
103 if (tolower(*s
) < tolower(*t
))
105 else if (tolower(*s
) > tolower(*t
))
115 else if (*s
== '\0' && *t
== '\0')
122 # endif /* !HAVE_STRNCASECMP */
126 * End of "$Id: string.c,v 1.5.2.4 2002/05/09 02:22:09 mike Exp $".