On x86 compilers without fastcall, simulate it when invoking traces and un-simulate...
[wine-gecko.git] / xpcom / glue / nsCRTGlue.h
bloba9fc43d24f3fb06262cd69cfff50681dc98e9e29
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is Mozilla XPCOM Glue.
16 * The Initial Developer of the Original Code is
17 * the Mozilla Foundation <http://www.mozilla.org/>.
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Benjamin Smedberg <benjamin@smedbergs.us>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef nsCRTGlue_h__
40 #define nsCRTGlue_h__
42 #include "nscore.h"
44 /**
45 * Scan a string for the first character that is *not* in a set of
46 * delimiters. If the string is only delimiter characters, the end of the
47 * string is returned.
49 * @param delims The set of delimiters (null-terminated)
50 * @param str The string to search (null-terminated)
52 NS_COM_GLUE const char*
53 NS_strspnp(const char *delims, const char *str);
55 /**
56 * Tokenize a string. This function is similar to the strtok function in the
57 * C standard library, but it does not use static variables to maintain state
58 * and is therefore thread and reentrancy-safe.
60 * Any leading delimiters in str are skipped. Then the string is scanned
61 * until an additional delimiter or end-of-string is found. The final
62 * delimiter is set to '\0'.
64 * @param delims The set of delimiters.
65 * @param str The string to search. This is an in-out parameter; it is
66 * reset to the end of the found token + 1, or to the
67 * end-of-string if there are no more tokens.
68 * @return The token. If no token is found (the string is only
69 * delimiter characters), NULL is returned.
71 NS_COM_GLUE char*
72 NS_strtok(const char *delims, char **str);
74 /**
75 * "strlen" for PRUnichar strings
77 NS_COM_GLUE PRUint32
78 NS_strlen(const PRUnichar *aString);
80 /**
81 * "strcmp" for PRUnichar strings
83 NS_COM_GLUE int
84 NS_strcmp(const PRUnichar *a, const PRUnichar *b);
86 /**
87 * "strdup" for PRUnichar strings, uses the NS_Alloc allocator.
89 NS_COM_GLUE PRUnichar*
90 NS_strdup(const PRUnichar *aString);
92 /**
93 * "strdup", but using the NS_Alloc allocator.
95 NS_COM_GLUE char*
96 NS_strdup(const char *aString);
98 /**
99 * strndup for PRUnichar strings... this function will ensure that the
100 * new string is null-terminated. Uses the NS_Alloc allocator.
102 NS_COM_GLUE PRUnichar*
103 NS_strndup(const PRUnichar *aString, PRUint32 aLen);
105 // The following case-conversion methods only deal in the ascii repertoire
106 // A-Z and a-z
108 // semi-private data declarations... don't use these directly.
109 class NS_COM_GLUE nsLowerUpperUtils {
110 public:
111 static const unsigned char kLower2Upper[256];
112 static const unsigned char kUpper2Lower[256];
115 inline char NS_ToUpper(char aChar)
117 return (char)nsLowerUpperUtils::kLower2Upper[(unsigned char)aChar];
120 inline char NS_ToLower(char aChar)
122 return (char)nsLowerUpperUtils::kUpper2Lower[(unsigned char)aChar];
125 NS_COM_GLUE PRBool NS_IsUpper(char aChar);
126 NS_COM_GLUE PRBool NS_IsLower(char aChar);
128 NS_COM_GLUE PRBool NS_IsAscii(PRUnichar aChar);
129 NS_COM_GLUE PRBool NS_IsAscii(const PRUnichar* aString);
130 NS_COM_GLUE PRBool NS_IsAsciiAlpha(PRUnichar aChar);
131 NS_COM_GLUE PRBool NS_IsAsciiDigit(PRUnichar aChar);
132 NS_COM_GLUE PRBool NS_IsAsciiWhitespace(PRUnichar aChar);
133 NS_COM_GLUE PRBool NS_IsAscii(const char* aString);
134 NS_COM_GLUE PRBool NS_IsAscii(const char* aString, PRUint32 aLength);
136 #endif // nsCRTGlue_h__