]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/string.c
2 * "$Id: string.c,v 1.3 1999/06/18 18:36:11 mike Exp $"
4 * String functions for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-1999 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
26 * strdup() - Duplicate a string.
27 * strcasecmp() - Do a case-insensitive comparison.
28 * strncasecmp() - Do a case-insensitive comparison on up to N chars.
32 * Include necessary headers...
39 * 'strdup()' - Duplicate a string.
43 char * /* O - New string pointer */
44 strdup(const char *s
) /* I - String to duplicate */
46 char *t
; /* New string pointer */
52 if ((t
= malloc(strlen(s
) + 1)) == NULL
)
55 return (strcpy(t
, s
));
57 # endif /* !HAVE_STRDUP */
61 * 'strcasecmp()' - Do a case-insensitive comparison.
64 # ifndef HAVE_STRCASECMP
65 int /* O - Result of comparison (-1, 0, or 1) */
66 strcasecmp(const char *s
, /* I - First string */
67 const char *t
) /* I - Second string */
69 while (*s
!= '\0' && *t
!= '\0')
71 if (tolower(*s
) < tolower(*t
))
73 else if (tolower(*s
) > tolower(*t
))
80 if (*s
== '\0' && *t
== '\0')
87 # endif /* !HAVE_STRCASECMP */
90 * 'strncasecmp()' - Do a case-insensitive comparison on up to N chars.
93 # ifndef HAVE_STRNCASECMP
94 int /* O - Result of comparison (-1, 0, or 1) */
95 strncasecmp(const char *s
, /* I - First string */
96 const char *t
, /* I - Second string */
97 size_t n
) /* I - Maximum number of characters to compare */
99 while (*s
!= '\0' && *t
!= '\0' && n
> 0)
101 if (tolower(*s
) < tolower(*t
))
103 else if (tolower(*s
) > tolower(*t
))
113 else if (*s
== '\0' && *t
== '\0')
120 # endif /* !HAVE_STRNCASECMP */
124 * End of "$Id: string.c,v 1.3 1999/06/18 18:36:11 mike Exp $".