2 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH DDI_STRTOUL 9F "May 13, 2004"
8 ddi_strtoul \- String conversion functions
13 #include <sys/sunddi.h>
15 \fBint\fR \fBddi_strtoul\fR(\fBconst char *\fR\fIstr\fR, \fBchar **\fR\fIendptr\fR, \fBint\fR \fIbase\fR,
16 \fBunsigned long *\fR\fIresult\fR);
22 Solaris DDI specific (Solaris DDI)
30 Pointer to a character string to be converted.
39 Post-conversion final string of unrecognized characters.
48 Radix used for conversion.
57 Pointer to variable which contains the converted value.
63 The \fBddi_strtoul()\fR function converts the initial portion of the string
64 pointed to by \fIstr\fR to a type \fBunsigned long\fR int representation and
65 stores the converted value in \fIresult\fR.
68 The function first decomposes the input string into three parts:
72 An initial (possibly empty) sequence of white-space characters
73 (' ', '\et', '\en', '\er', '\ef')
78 A subject sequence interpreted as an integer represented in some radix
79 determined by the value of \fIbase\fR
84 A final string of one or more unrecognized characters, including the
85 terminating null byte of the input string.
89 The \fBddi_strtoul()\fR function then attempts to convert the subject sequence
90 to an \fBunsigned\fR integer and returns the result.
93 If the value of \fIbase\fR is 0, the expected form of the subject sequence is
94 that of a decimal constant, octal constant or hexadecimal constant, any of
95 which may be preceded by a plus ("+") or minus ("-") sign. A decimal constant
96 begins with a non-zero digit, and consists of a sequence of decimal digits. An
97 octal constant consists of the prefix 0 optionally followed by a sequence of
98 the digits 0 to 7 only. A hexadecimal constant consists of the prefix 0x or 0X
99 followed by a sequence of the decimal digits and letters a (or A) to f (or F)
100 with values 10 to 15 respectively.
103 If the value of \fIbase\fR is between 2 and 36, the expected form of the
104 subject sequence is a sequence of letters and digits representing an integer
105 with the radix specified by \fIbase\fR, optionally preceded by a plus or minus
106 sign. The letters from a (or A) to z (or Z) inclusive are ascribed the values
107 10 to 35 and only letters whose ascribed values are less than that of
108 \fIbase\fR are permitted. If the value of \fIbase\fR is 16, the characters 0x
109 or 0X may optionally precede the sequence of letters and digits, following the
113 The subject sequence is defined as the longest initial subsequence of the
114 input string, starting with the first non-white-space character that is of the
115 expected form. The subject sequence contains no characters if the input string
116 is empty or consists entirely of white-space characters, or if the first
117 non-white-space character is other than a sign or a permissible letter or
121 If the subject sequence has the expected form and the value of \fIbase\fR is
122 0, the sequence of characters starting with the first digit is interpreted as
123 an integer constant. If the subject sequence has the expected form and the
124 value of \fIbase\fR is between 2 and 36, it is used as the \fIbase\fR for
125 conversion, ascribing to each letter its value as given above. If the subject
126 sequence begins with a minus sign, the value resulting from the conversion is
127 negated. A pointer to the final string is stored in the object pointed to by
128 \fIendptr\fR, provided that \fIendptr\fR is not a null pointer.
131 If the subject sequence is empty or does not have the expected form, no
132 conversion is performed and the value of \fIstr\fR is stored in the object
133 pointed to by \fIendptr\fR, provided that \fIendptr\fR is not a null pointer.
137 Upon successful completion, \fBddi_strtoul()\fR returns \fB0\fR and stores the
138 converted value in \fIresult\fR. If no conversion is performed due to invalid
139 \fIbase\fR, \fBddi_strtoul()\fR returns \fBEINVAL\fR and the variable pointed
140 by \fIresult\fR is not changed.
143 If the correct value is outside the range of representable values,
144 \fBddi_strtoul()\fR returns \fBERANGE\fR and the value pointed to by
145 \fIresult\fR is not changed.
149 The \fBddi_strtoul()\fR function may be called from user, kernel or interrupt
154 \fIWriting Device Drivers\fR