2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * File: sbstdinc.c $TOG: sbstdinc.c /main/5 1999/10/14 15:06:26 mgreess $
27 * (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
29 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
30 * (c) Copyright 1993, 1994 International Business Machines Corp. *
31 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
32 * (c) Copyright 1993, 1994 Novell, Inc. *
35 #define SBSTDINC_H_NO_REDEFINE
37 #include <bms/sbport.h> /* NOTE: sbport.h must be the first include. */
41 static XeChar XESTRING_SAFE_NULL[1] = {(XeChar)0};
43 /************************************************************************/
44 /* Routines from <string.h> */
45 /************************************************************************/
47 XeString Xestrcat(XeString s1, ConstXeString s2)
49 if (!s1) return XeString_NULL;
52 return (XeString) strcat(s1, s2);
55 XeString Xestrncat(XeString s1, ConstXeString s2, size_t n)
57 if (!s1) return XeString_NULL;
60 return (XeString) strncat(s1, s2, n);
63 int Xestrcmp(ConstXeString s1, ConstXeString s2)
65 if (s1 == s2) return 0;
67 const XeChar * p1 = (s1) ? s1 : XESTRING_SAFE_NULL;
68 const XeChar * p2 = (s2) ? s2 : XESTRING_SAFE_NULL;
70 return strcmp(p1, p2);
74 int Xestrncmp(ConstXeString s1, ConstXeString s2, size_t n)
76 if (s1 == s2) return 0;
78 ConstXeString p1 = (s1) ? s1 : XESTRING_SAFE_NULL;
79 ConstXeString p2 = (s2) ? s2 : XESTRING_SAFE_NULL;
80 return strncmp( (char *) p1, (char *) p2, n);
84 XeString Xestrcpy(XeString s1, ConstXeString s2)
92 return (XeString) strcpy(s1, s2);
95 XeString Xestrncpy(XeString s1, ConstXeString s2, size_t n)
103 return (XeString) strncpy(s1, s2, n);
106 int Xestrcoll(ConstXeString s1, ConstXeString s2)
108 if (s1 == s2) return 0;
110 XeString p1 = (s1) ? (XeString) s1 : XESTRING_SAFE_NULL;
111 XeString p2 = (s2) ? (XeString) s2 : XESTRING_SAFE_NULL;
112 return strcoll(p1, p2);
116 size_t Xestrxfrm(XeString s1, ConstXeString s2, size_t n)
118 return strxfrm(s1, s2, n);
121 XeString Xestrchr(ConstXeString s, int c)
123 if (!s) return XeString_NULL;
125 return (XeString) strchr(s, c);
128 XeString Xestrrchr(ConstXeString s, int c)
130 if (!s) return XeString_NULL;
132 return (XeString) strrchr(s, c);
135 XeString Xestrpbrk(ConstXeString s1, ConstXeString s2)
137 if (!s1) return XeString_NULL;
138 if (!s2) return XeString_NULL;
140 return (XeString) strpbrk(s1, s2);
143 XeString Xestrstr(ConstXeString s1, ConstXeString s2)
145 if (!s1) return XeString_NULL;
146 if (!s2) return XeString_NULL;
148 return (XeString) strstr(s1, s2);
151 XeString Xestrtok(XeString s1, ConstXeString s2)
153 /* s1 is null except after the first call */
154 if (!s2) return XeString_NULL;
156 return (XeString) strtok(s1, s2);
159 size_t Xestrlen(ConstXeString const s)
161 if (!s) return (size_t)0;
163 return strlen((char *) s);
166 XeString Xestrdup(ConstXeString s)
168 if (!s) return XeString_NULL;
170 return (XeString) strdup(s);