![]() |
|
|||
File indexing completed on 2025-05-11 08:24:15
0001 /*- 0002 * SPDX-License-Identifier: BSD-3-Clause 0003 * 0004 * Copyright (c) 1999 0005 * University of California. All rights reserved. 0006 * 0007 * Redistribution and use in source and binary forms, with or without 0008 * modification, are permitted provided that the following conditions 0009 * are met: 0010 * 1. Redistributions of source code must retain the above copyright 0011 * notice, this list of conditions and the following disclaimer. 0012 * 2. Redistributions in binary form must reproduce the above copyright 0013 * notice, this list of conditions and the following disclaimer in the 0014 * documentation and/or other materials provided with the distribution. 0015 * 3. Neither the name of the author nor the names of any co-contributors 0016 * may be used to endorse or promote products derived from this software 0017 * without specific prior written permission. 0018 * 0019 * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS 0020 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 0021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0022 * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY 0023 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 0024 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 0025 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 0027 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 0028 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 0029 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0030 */ 0031 0032 #include <sys/cdefs.h> 0033 __FBSDID("$FreeBSD$"); 0034 0035 #include <sys/types.h> 0036 0037 #include <crypt.h> 0038 0039 static const char itoa64[] = /* 0 ... 63 => ascii - 64 */ 0040 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 0041 0042 void 0043 _crypt_to64(char *s, u_long v, int n) 0044 { 0045 while (--n >= 0) { 0046 *s++ = itoa64[v&0x3f]; 0047 v >>= 6; 0048 } 0049 } 0050 0051 void 0052 b64_from_24bit(uint8_t B2, uint8_t B1, uint8_t B0, int n, int *buflen, char **cp) 0053 { 0054 uint32_t w; 0055 int i; 0056 0057 #if defined(__rtems__) 0058 w = ((uint32_t)B2 << 16) | ((uint32_t)B1 << 8) | B0; 0059 #else 0060 w = (B2 << 16) | (B1 << 8) | B0; 0061 #endif 0062 for (i = 0; i < n; i++) { 0063 **cp = itoa64[w&0x3f]; 0064 (*cp)++; 0065 if ((*buflen)-- < 0) 0066 break; 0067 w >>= 6; 0068 } 0069 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |