1
Content-type: text/html
3
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<HTML><HEAD><TITLE>Man page of IPSEC_TTOUL</TITLE>
7
Section: C Library Functions (3)<BR>Updated: 16 Aug 2000<BR><A HREF="#index">Index</A>
8
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
11
<A NAME="lbAB"> </A>
14
ipsec ttoul, ultot - convert unsigned-long numbers to and from text
15
<A NAME="lbAC"> </A>
18
<B>#include <<A HREF="file:///usr/include/freeswan.h">freeswan.h</A>></B>
21
<B>const char *ttoul(const char *src, size_t srclen,</B>
25
<B>int base, unsigned long *n);</B>
29
<B>size_t ultot(unsigned long n, int format, char *dst,</B>
33
<B>size_t dstlen);</B>
35
<A NAME="lbAD"> </A>
40
converts a text-string number into a binary
46
does the reverse conversion, back to a text version.
49
Numbers are specified in text as
53
octal with a leading zero (e.g.
57
or hexadecimal with a leading
64
in either upper or lower case.
73
specifies the length of the string pointed to by
76
it is an error for there to be anything else
77
(e.g., a terminating NUL) within that length.
78
As a convenience for cases where an entire NUL-terminated string is
105
in which case the number supplied is assumed to be of that form
116
in which case the number is examined for a leading zero
120
to determine its base.
129
specifies the size of the
133
under no circumstances are more than
139
A result which will not fit is truncated.
142
can be zero, in which case
145
need not be valid and no result is written,
146
but the return value is unaffected;
147
in all other cases, the (possibly truncated) result is NUL-terminated.
151
header file defines a constant,
154
which is the size of a buffer just large enough for worst-case results.
167
octal conversion with leading
170
<DT><B> 8</B><DD>
171
octal conversion with no leading
181
hexadecimal conversion, including leading
185
hexadecimal conversion with no leading
192
except padded on left with
195
to eight digits (full width of a 32-bit number)
203
returns NULL for success and
204
a pointer to a string-literal error message for failure;
211
for a failure, and otherwise
212
returns the size of buffer which would
214
accommodate the full conversion result, including terminating NUL
215
(it is the caller's responsibility to check this against the size of
216
the provided buffer to determine whether truncation has occurred).
217
<A NAME="lbAE"> </A>
220
<A HREF="/cgi-bin/man/man2html?3+atol">atol</A>(3), <A HREF="/cgi-bin/man/man2html?3+strtoul">strtoul</A>(3)
221
<A NAME="lbAF"> </A>
232
non-digit character found;
233
number too large for an
234
<B>unsigned long</B>.
245
<A NAME="lbAG"> </A>
248
Written for the FreeS/WAN project by Henry Spencer.
249
<A NAME="lbAH"> </A>
268
is a bit of a kludge.
271
The restriction of error reports to literal strings
272
(so that callers don't need to worry about freeing them or copying them)
273
does limit the precision of error reporting.
276
The error-reporting convention lends itself to slightly obscure code,
277
because many readers will not think of NULL as signifying success.
278
A good way to make it clearer is to write something like:
283
<B>const char *error;</B>
285
<B>error = ttoul( /* ... */ );</B>
286
<B>if (error != NULL) {</B>
287
<B> /* something went wrong */</B>
295
<A NAME="index"> </A><H2>Index</H2>
297
<DT><A HREF="#lbAB">NAME</A><DD>
298
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
299
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
300
<DT><A HREF="#lbAE">SEE ALSO</A><DD>
301
<DT><A HREF="#lbAF">DIAGNOSTICS</A><DD>
302
<DT><A HREF="#lbAG">HISTORY</A><DD>
303
<DT><A HREF="#lbAH">BUGS</A><DD>
306
This document was created by
307
<A HREF="/cgi-bin/man/man2html">man2html</A>,
308
using the manual pages.<BR>
309
Time: 10:29:43 GMT, June 17, 2004