Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / ddi_strtol.9f
blob102e332e7c7ea440f93ebcc3d2bb6b06280e6a05
1 '\" te
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_STRTOL 9F "May 13, 2004"
7 .SH NAME
8 ddi_strtol \- String conversion routines
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/ddi.h>
13 #include <sys/sunddi.h>
15 \fBint\fR \fBddi_strtol\fR(\fBconst char *\fR\fIstr\fR, \fBchar **\fR\fIendptr\fR, \fBint\fR \fIbase\fR,
16      \fBlong *\fR\fIresult\fR);
17 .fi
19 .SH INTERFACE LEVEL
20 .sp
21 .LP
22 Solaris DDI specific (Solaris DDI)
23 .SH PARAMETERS
24 .sp
25 .ne 2
26 .na
27 \fB\fIstr\fR \fR
28 .ad
29 .RS 11n
30 Pointer to a character string to be converted.
31 .RE
33 .sp
34 .ne 2
35 .na
36 \fB\fIendptr\fR \fR
37 .ad
38 .RS 11n
39 Post-conversion final string of unrecognized characters.
40 .RE
42 .sp
43 .ne 2
44 .na
45 \fB\fIbase\fR\fR
46 .ad
47 .RS 11n
48 Radix used for conversion.
49 .RE
51 .sp
52 .ne 2
53 .na
54 \fB\fIresult\fR \fR
55 .ad
56 .RS 11n
57 Pointer to variable which contains the converted value.
58 .RE
60 .SH DESCRIPTION
61 .sp
62 .LP
63 The \fBddi_strtol()\fR function converts the initial portion of the string
64 pointed to by \fIstr\fR to a type \fBlong\fR int representation and stores the
65 converted value in result.
66 .sp
67 .LP
68 The  function first decomposes the input string into three parts:
69 .RS +4
70 .TP
72 An initial (possibly empty) sequence of white-space characters
73 (' ', '\et', '\en', '\er', '\ef')
74 .RE
75 .RS +4
76 .TP
78 A subject sequence interpreted as an integer represented in some radix
79 determined by the value of \fIbase\fR
80 .RE
81 .RS +4
82 .TP
84 A final  string of one or more unrecognized characters, including the
85 terminating null byte of the input string.
86 .RE
87 .sp
88 .LP
89 The \fBddi_strtol()\fR function then attempts to convert the subject sequence
90 to an integer and returns the result.
91 .sp
92 .LP
93 If the value of \fIbase\fR is 0, the expected form of the subject sequence is a
94 decimal constant, octal constant or hexadecimal constant, any of which may be
95 preceded by a plus ("+") or minus ("-") sign. A decimal constant begins with a
96 non-zero digit, and consists of a sequence of decimal digits. An octal
97 constant consists of the prefix 0 optionally followed by a sequence of the
98 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
110 sign, if present.
113 The subject sequence is defined as the longest initial subsequence of the input
114 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
118 digit.
121 If the subject sequence has the expected form and the value of \fIbase\fR is 0,
122 the sequence of characters starting with the first digit is interpreted as an
123 integer constant. If  the subject sequence has the expected form and the value
124 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.
134 .SH RETURN VALUES
137 Upon successful completion, \fBddi_strtol()\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_strtol()\fR returns \fBEINVAL\fR and the variable pointed by
140 \fIresult\fR is not changed.
143 If the correct value is outside the range  of representable values,
144 \fBddi_strtol()\fR returns \fBERANGE\fR and the value pointed to by
145 \fIresult\fR is not changed.
146 .SH CONTEXT
149 The \fBddi_strtol()\fR function may be called from user, kernel or interrupt
150 context.
151 .SH SEE ALSO
154 \fIWriting Device Drivers\fR