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