]> git.ipfire.org Git - thirdparty/strongswan.git/blame - doc/manpage.d/ipsec_atoul.3.html
- import of strongswan-2.7.0
[thirdparty/strongswan.git] / doc / manpage.d / ipsec_atoul.3.html
CommitLineData
997358a6
MW
1Content-type: text/html
2
3<HTML><HEAD><TITLE>Manpage of IPSEC_ATOUL</TITLE>
4</HEAD><BODY>
5<H1>IPSEC_ATOUL</H1>
6Section: C Library Functions (3)<BR>Updated: 11 June 2001<BR><A HREF="#index">Index</A>
7<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
8
9
10<A NAME="lbAB">&nbsp;</A>
11<H2>NAME</H2>
12
13ipsec atoul, ultoa - convert unsigned-long numbers to and from ASCII
14<A NAME="lbAC">&nbsp;</A>
15<H2>SYNOPSIS</H2>
16
17<B>#include &lt;<A HREF="file:/usr/include/freeswan.h">freeswan.h</A>&gt;</B>
18
19<P>
20<B>const char *atoul(const char *src, size_t srclen,</B>
21
22<BR>
23&nbsp;
24<B>int base, unsigned long *n);</B>
25
26<BR>
27
28<B>size_t ultoa(unsigned long n, int base, char *dst,</B>
29
30<BR>
31&nbsp;
32<B>size_t dstlen);</B>
33
34<A NAME="lbAD">&nbsp;</A>
35<H2>DESCRIPTION</H2>
36
37These functions are obsolete; see
38<I><A HREF="ipsec_ttoul.3.html">ipsec_ttoul</A></I>(3)
39
40for their replacements.
41<P>
42
43<I>Atoul</I>
44
45converts an ASCII number into a binary
46<B>unsigned long</B>
47
48value.
49<I>Ultoa</I>
50
51does the reverse conversion, back to an ASCII version.
52<P>
53
54Numbers are specified in ASCII as
55decimal (e.g.
56<B>123</B>),
57
58octal with a leading zero (e.g.
59<B>012</B>,
60
61which has value 10),
62or hexadecimal with a leading
63<B>0x</B>
64
65(e.g.
66<B>0x1f</B>,
67
68which has value 31)
69in either upper or lower case.
70<P>
71
72The
73<I>srclen</I>
74
75parameter of
76<I>atoul</I>
77
78specifies the length of the ASCII string pointed to by
79<I>src</I>;
80
81it is an error for there to be anything else
82(e.g., a terminating NUL) within that length.
83As a convenience for cases where an entire NUL-terminated string is
84to be converted,
85a
86<I>srclen</I>
87
88value of
89<B>0</B>
90
91is taken to mean
92<B>strlen(src)</B>.
93
94<P>
95
96The
97<I>base</I>
98
99parameter of
100<I>atoul</I>
101
102can be
103<B>8</B>,
104
105<B>10</B>,
106
107or
108<B>16</B>,
109
110in which case the number supplied is assumed to be of that form
111(and in the case of
112<B>16</B>,
113
114to lack any
115<B>0x</B>
116
117prefix).
118It can also be
119<B>0</B>,
120
121in which case the number is examined for a leading zero
122or a leading
123<B>0x</B>
124
125to determine its base,
126or
127<B>13</B>
128
129(halfway between 10 and 16),
130which has the same effect as
131<B>0</B>
132
133except that a non-hexadecimal
134number is considered decimal regardless of any leading zero.
135<P>
136
137The
138<I>dstlen</I>
139
140parameter of
141<I>ultoa</I>
142
143specifies the size of the
144<I>dst</I>
145
146parameter;
147under no circumstances are more than
148<I>dstlen</I>
149
150bytes written to
151<I>dst</I>.
152
153A result which will not fit is truncated.
154<I>Dstlen</I>
155
156can be zero, in which case
157<I>dst</I>
158
159need not be valid and no result is written,
160but the return value is unaffected;
161in all other cases, the (possibly truncated) result is NUL-terminated.
162<P>
163
164The
165<I>base</I>
166
167parameter of
168<I>ultoa</I>
169
170must be
171<B>8</B>,
172
173<B>10</B>,
174
175or
176<B>16</B>.
177
178<P>
179
180<I>Atoul</I>
181
182returns NULL for success and
183a pointer to a string-literal error message for failure;
184see DIAGNOSTICS.
185<I>Ultoa</I>
186
187returns the size of buffer which would
188be needed to
189accommodate the full conversion result, including terminating NUL;
190it is the caller's responsibility to check this against the size of
191the provided buffer to determine whether truncation has occurred.
192<A NAME="lbAE">&nbsp;</A>
193<H2>SEE ALSO</H2>
194
195<A HREF="atol.3.html">atol</A>(3), <A HREF="strtoul.3.html">strtoul</A>(3)
196<A NAME="lbAF">&nbsp;</A>
197<H2>DIAGNOSTICS</H2>
198
199Fatal errors in
200<I>atoul</I>
201
202are:
203empty input;
204unknown
205<I>base</I>;
206
207non-digit character found;
208number too large for an
209<B>unsigned long</B>.
210
211<A NAME="lbAG">&nbsp;</A>
212<H2>HISTORY</H2>
213
214Written for the FreeS/WAN project by Henry Spencer.
215<A NAME="lbAH">&nbsp;</A>
216<H2>BUGS</H2>
217
218There is no provision for reporting an invalid
219<I>base</I>
220
221parameter given to
222<I>ultoa</I>.
223
224<P>
225
226The restriction of error reports to literal strings
227(so that callers don't need to worry about freeing them or copying them)
228does limit the precision of error reporting.
229<P>
230
231The error-reporting convention lends itself to slightly obscure code,
232because many readers will not think of NULL as signifying success.
233A good way to make it clearer is to write something like:
234<P>
235
236<DL COMPACT><DT><DD>
237<PRE>
238<B>const char *error;</B>
239
240<B>error = atoul( /* ... */ );</B>
241<B>if (error != NULL) {</B>
242<B> /* something went wrong */</B>
243</PRE>
244
245</DL>
246
247<P>
248
249<HR>
250<A NAME="index">&nbsp;</A><H2>Index</H2>
251<DL>
252<DT><A HREF="#lbAB">NAME</A><DD>
253<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
254<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
255<DT><A HREF="#lbAE">SEE ALSO</A><DD>
256<DT><A HREF="#lbAF">DIAGNOSTICS</A><DD>
257<DT><A HREF="#lbAG">HISTORY</A><DD>
258<DT><A HREF="#lbAH">BUGS</A><DD>
259</DL>
260<HR>
261This document was created by
262<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
263using the manual pages.<BR>
264Time: 21:40:17 GMT, November 11, 2003
265</BODY>
266</HTML>