1 Content-type: text/html
3 <HTML><HEAD><TITLE>Manpage of IPSEC_TTOUL
</TITLE>
6 Section: C Library Functions (
3)
<BR>Updated:
16 Aug
2000<BR><A HREF=
"#index">Index
</A>
7 <A HREF=
"http://localhost/cgi-bin/man/man2html">Return to Main Contents
</A><HR>
10 <A NAME=
"lbAB"> </A>
13 ipsec ttoul, ultot - convert unsigned-long numbers to and from text
14 <A NAME=
"lbAC"> </A>
17 <B>#include
<<A HREF=
"file:/usr/include/freeswan.h">freeswan.h
</A>></B>
20 <B>const char *ttoul(const char *src, size_t srclen,
</B>
24 <B>int base, unsigned long *n);
</B>
28 <B>size_t ultot(unsigned long n, int format, char *dst,
</B>
32 <B>size_t dstlen);
</B>
34 <A NAME=
"lbAD"> </A>
39 converts a text-string number into a binary
45 does the reverse conversion, back to a text version.
48 Numbers are specified in text as
52 octal with a leading zero (e.g.
56 or hexadecimal with a leading
63 in either upper or lower case.
72 specifies the length of the string pointed to by
75 it is an error for there to be anything else
76 (e.g., a terminating NUL) within that length.
77 As a convenience for cases where an entire NUL-terminated string is
104 in which case the number supplied is assumed to be of that form
115 in which case the number is examined for a leading zero
119 to determine its base.
128 specifies the size of the
132 under no circumstances are more than
138 A result which will not fit is truncated.
141 can be zero, in which case
144 need not be valid and no result is written,
145 but the return value is unaffected;
146 in all other cases, the (possibly truncated) result is NUL-terminated.
150 header file defines a constant,
153 which is the size of a buffer just large enough for worst-case results.
166 octal conversion with leading
169 <DT><B> 8</B><DD>
170 octal conversion with no leading
180 hexadecimal conversion, including leading
184 hexadecimal conversion with no leading
191 except padded on left with
194 to eight digits (full width of a
32-bit number)
202 returns NULL for success and
203 a pointer to a string-literal error message for failure;
210 for a failure, and otherwise
211 returns the size of buffer which would
213 accommodate the full conversion result, including terminating NUL
214 (it is the caller's responsibility to check this against the size of
215 the provided buffer to determine whether truncation has occurred).
216 <A NAME=
"lbAE"> </A>
219 <A HREF=
"atol.3.html">atol
</A>(
3),
<A HREF=
"strtoul.3.html">strtoul
</A>(
3)
220 <A NAME=
"lbAF"> </A>
231 non-digit character found;
232 number too large for an
233 <B>unsigned long
</B>.
244 <A NAME=
"lbAG"> </A>
247 Written for the FreeS/WAN project by Henry Spencer.
248 <A NAME=
"lbAH"> </A>
267 is a bit of a kludge.
270 The restriction of error reports to literal strings
271 (so that callers don't need to worry about freeing them or copying them)
272 does limit the precision of error reporting.
275 The error-reporting convention lends itself to slightly obscure code,
276 because many readers will not think of NULL as signifying success.
277 A good way to make it clearer is to write something like:
282 <B>const char *error;
</B>
284 <B>error = ttoul( /* ... */ );
</B>
285 <B>if (error != NULL) {
</B>
286 <B> /* something went wrong */
</B>
294 <A NAME=
"index"> </A><H2>Index
</H2>
296 <DT><A HREF=
"#lbAB">NAME
</A><DD>
297 <DT><A HREF=
"#lbAC">SYNOPSIS
</A><DD>
298 <DT><A HREF=
"#lbAD">DESCRIPTION
</A><DD>
299 <DT><A HREF=
"#lbAE">SEE ALSO
</A><DD>
300 <DT><A HREF=
"#lbAF">DIAGNOSTICS
</A><DD>
301 <DT><A HREF=
"#lbAG">HISTORY
</A><DD>
302 <DT><A HREF=
"#lbAH">BUGS
</A><DD>
305 This document was created by
306 <A HREF=
"http://localhost/cgi-bin/man/man2html">man2html
</A>,
307 using the manual pages.
<BR>
308 Time:
21:
40:
18 GMT, November
11,
2003