8999 SMBIOS: cleanup 32-bit specific code
[unleashed.git] / usr / src / man / man3c / wcstoul.3c
blobf1b8c30f992815260bfcf3cb296b77d5aae0e9e2
1 '\" te
2 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.  Portions Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH WCSTOUL 3C "Nov 1, 2003"
11 .SH NAME
12 wcstoul, wcstoull \- convert wide-character string to unsigned long
13 .SH SYNOPSIS
14 .LP
15 .nf
16 #include <wchar.h>
18 \fBunsigned long\fR  \fBwcstoul\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
19      \fBwchar_t **restrict\fR \fIendptr\fR, \fBint\fR \fIbase\fR);
20 .fi
22 .LP
23 .nf
24 \fBunsigned long long\fR \fBwcstoull\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
25      \fBwchar_t **restrict\fR \fIendptr\fR, \fBint\fR \fIbase\fR);
26 .fi
28 .SH DESCRIPTION
29 .sp
30 .LP
31 The \fBwcstoul()\fR and \fBwcstoull()\fR functions convert the initial portion
32 of the wide-character string pointed to by \fInptr\fR to \fBunsigned long\fR
33 and \fBunsigned long long\fR representation, respectively. First they decompose
34 the input wide-character string  into three parts:
35 .RS +4
36 .TP
38 An initial, possibly empty, sequence of white-space wide-character codes (as
39 specified by the function \fBiswspace\fR(3C))
40 .RE
41 .RS +4
42 .TP
44  Asubject sequence interpreted as an integer represented in some radix
45 determined by the value of \fIbase\fR
46 .RE
47 .RS +4
48 .TP
50 a final wide-character string of one or more unrecognized wide-character
51 codes, including the terminating null wide-character code of the input wide
52 character string
53 .RE
54 .sp
55 .LP
56 They then attempt to convert the subject sequence to an unsigned integer and
57 return the result.
58 .sp
59 .LP
60 If the value of \fIbase\fR is 0, the expected form of the subject sequence is
61 that of a decimal constant, an octal constant, or a hexadecimal constant, any
62 of which may be preceded by a `+' or a `\(mi' sign. A decimal constant begins
63 with a non-zero digit, and consists of a sequence of decimal digits. An octal
64 constant consists of the prefix `0', optionally followed by a sequence of the
65 digits `0' to `7' only. A hexadecimal constant consists of the prefix `0x' or
66 `0X', followed by a sequence of the decimal digits and letters `a' (or `A') to
67 `f' (or `F'), with values 10 to 15, respectively.
68 .sp
69 .LP
70 If the value of \fIbase\fR is between 2 and 36, the expected form of the
71 subject sequence is a sequence of letters and digits representing an integer
72 with the radix specified by  \fIbase\fR, optionally preceded by a `+' or a
73 `\(mi' sign, but not including an integer suffix. The letters from `a' (or `A')
74 to `z' (or `Z') inclusive are ascribed the values 10 to 35; only letters whose
75 ascribed values are less than that of \fIbase\fR are permitted. If the value of
76 \fIbase\fR is 16, the wide-character codes `0x' or `0X' may optionally precede
77 the sequence of letters and digits, following the sign, if present.
78 .sp
79 .LP
80 The subject sequence is defined as the longest initial subsequence of the input
81 wide-character string, starting with the first wide-character code that is not
82 a white space and is of the expected form. The subject sequence contains no
83 wide-character codes if the input wide-character string is empty or consists
84 entirely of white-space wide-character codes, or if the first wide-character
85 code that is not a white space  is other than a sign or a permissible letter or
86 digit.
87 .sp
88 .LP
89 If the subject sequence has the expected form and the value of \fIbase\fR is 0,
90 the sequence of wide-character codes starting with the first digit is
91 interpreted as an integer constant. If the subject sequence has the expected
92 form and the value of \fIbase\fR is between 2 and 36, it is used as the base
93 for conversion, ascribing to each letter its value as given above. If the
94 subject sequence begins with a minus sign, the value resulting from the
95 conversion is negated. A pointer to the final wide character string is  stored
96 in the object pointed to by \fIendptr\fR, provided that  \fIendptr\fR is not a
97 null pointer.
98 .sp
99 .LP
100 If the subject sequence is empty or does not have the expected form, no
101 conversion is performed; the value of \fInptr\fR is stored in the object
102 pointed to by \fIendptr\fR, provided that  \fIendptr\fR is not a null pointer.
105 The \fBwcstoul()\fR function does not change the setting of \fBerrno\fR if
106 successful.
109 Since 0, {\fBULONG_MAX\fR}, and {\fBULLONG_MAX\fR} are returned on error and 0
110 is also a valid return on success, an application wanting to check for error
111 situations should set \fBerrno\fR to 0, then call \fBwcstoul()\fR or
112 \fBwcstoull()\fR, then check  \fBerrno\fR.
115 The \fBwcstoul()\fR and \fBwcstoull()\fR functions do not change the setting of
116 \fBerrno\fR if successful.
117 .SH RETURN VALUE
120 Upon successful completion, \fBwcstoul()\fR and \fBwcstoull()\fR return the
121 converted value, if any. If no conversion could be performed, \fB0\fR is
122 returned and \fBerrno\fR may be set to indicate the error. If the correct value
123 is outside the range of representable values, {\fBULONG_MAX\fR} or
124 {\fBULLONG_MAX\fR}, respectively, is returned and \fBerrno\fR is set to
125 \fBERANGE\fR.
126 .SH ERRORS
129 The \fBwcstoul()\fR and \fBwcstoull()\fR functions will fail if:
131 .ne 2
133 \fB\fBEINVAL\fR\fR
135 .RS 10n
136 The value of \fIbase\fR is not supported.
140 .ne 2
142 \fB\fBERANGE\fR\fR
144 .RS 10n
145 The value to be returned is not representable.
150 The \fBwcstoul()\fR and \fBwcstoull()\fR functions may fail if:
152 .ne 2
154 \fB\fBEINVAL\fR\fR
156 .RS 10n
157 No conversion could be performed.
160 .SH USAGE
163 Unlike \fBwcstod\fR(3C) and \fBwcstol\fR(3C), \fBwcstoul()\fR and
164 \fBwcstoull()\fR must always return a non-negative number; using the return
165 value of \fBwcstoul()\fR for out-of-range numbers with \fBwcstoul()\fR or
166 \fBwcstoull()\fR could cause more severe problems than just loss of precision
167 if those numbers can ever be negative.
168 .SH ATTRIBUTES
171 See \fBattributes\fR(5) for descriptions of the following attributes:
176 box;
177 l | l
178 l | l .
179 ATTRIBUTE TYPE  ATTRIBUTE VALUE
181 Interface Stability     Standard
183 MT-Level        MT-Safe
186 .SH SEE ALSO
189 \fBisspace\fR(3C), \fBiswalpha\fR(3C), \fBscanf\fR(3C), \fBwcstod\fR(3C),
190 \fBwcstol\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)