1.\" $NetBSD: a64l.3,v 1.10 2010/05/06 18:55:34 jruoho Exp $ 2.\" 3.\" Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Klaus Klein. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd May 6, 2010 31.Dt A64L 3 32.Os 33.Sh NAME 34.Nm a64l , 35.Nm l64a , 36.Nm l64a_r 37.Nd "convert between a long integer and a base-64 ASCII string" 38.Sh LIBRARY 39.Lb libc 40.Sh SYNOPSIS 41.In stdlib.h 42.Ft long 43.Fn a64l "const char *s" 44.Ft char * 45.Fn l64a "long int l" 46.Ft int 47.Fn l64a_r "long int l" "char *buffer" "int buflen" 48.Sh DESCRIPTION 49The 50.Fn a64l 51and 52.Fn l64a 53functions convert between a long integer and its base-64 ASCII string 54representation. 55.Pp 56The characters used to represent ``digits'' are 57`.' for 0, 58`/' for 1, 59`0' - `9' for 2 - 11, 60`A' - `Z' for 12 - 37, and 61`a' - `z' for 38 - 63. 62.Pp 63.Fn a64l 64takes a pointer to a NUL-terminated base-64 ASCII string 65representation, 66.Fa s , 67and returns the corresponding long integer value. 68.Pp 69.Fn l64a 70takes a long integer value, 71.Fa l , 72and returns a pointer to the corresponding NUL-terminated base-64 73ASCII string representation. 74.Pp 75.Fn l64a_r 76performs a conversion identical to that of 77.Fn l64a 78and stores the resulting representation in the memory area pointed to by 79.Fa buffer , 80consuming at most 81.Fa buflen 82characters including the terminating NUL character. 83.Sh RETURN VALUES 84On successful completion, 85.Fn a64l 86returns the long integer value corresponding to the input string. 87If the string pointed to by 88.Fa s 89is an empty string, 90.Fn a64l 91returns a value of 0L. 92.Pp 93.Fn l64a 94returns a pointer to the base-64 ASCII string representation corresponding to 95the input value. 96If 97.Fa l 98is 0L, 99.Fn l64a 100returns a pointer to an empty string. 101.Pp 102On successful completion, 103.Fn l64a_r 104returns 0; if 105.Fa buffer 106is of insufficient length, -1 is returned. 107.Sh SEE ALSO 108.Xr strtol 3 109.Sh STANDARDS 110The 111.Fn a64l 112and 113.Fn l64a 114functions conform to 115.St -xpg4.2 116and 117.St -p1003.1-2004 . 118The 119.Fn l64a_r 120function conforms to 121.St -svid4 , 122Multithreading Extension. 123.Sh BUGS 124The 125.Fn l64a 126function is not reentrant. 127The value returned by it points into a static buffer area; 128subsequent calls to 129.Fn la64a 130may overwrite this buffer. 131In multi-threaded applications, 132.Fn l64a_r 133should be used instead. 134