]>
Commit | Line | Data |
---|---|---|
bfff8b1b | 1 | /* Copyright (C) 1995-2017 Free Software Foundation, Inc. |
2c6fe0bd UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. | |
60478656 | 4 | |
2c6fe0bd | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
60478656 | 9 | |
2c6fe0bd UD |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
60478656 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
60478656 RM |
18 | |
19 | #include <stdlib.h> | |
20 | ||
21 | /* Conversion table. */ | |
1d8dc429 | 22 | static const char conv_table[64] = |
60478656 RM |
23 | { |
24 | '.', '/', '0', '1', '2', '3', '4', '5', | |
25 | '6', '7', '8', '9', 'A', 'B', 'C', 'D', | |
26 | 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', | |
27 | 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', | |
28 | 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', | |
29 | 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', | |
30 | 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', | |
31 | 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' | |
32 | }; | |
33 | ||
1d8dc429 | 34 | char * |
9d46370c | 35 | l64a (long int n) |
60478656 | 36 | { |
dd7d45e8 | 37 | unsigned long int m = (unsigned long int) n; |
60478656 RM |
38 | static char result[7]; |
39 | int cnt; | |
40 | ||
9cf90923 UD |
41 | /* The standard says that only 32 bits are used. */ |
42 | m &= 0xffffffff; | |
43 | ||
44 | if (m == 0ul) | |
dd7d45e8 | 45 | /* The value for N == 0 is defined to be the empty string. */ |
2c6fe0bd UD |
46 | return (char *) ""; |
47 | ||
ab1c32a6 | 48 | for (cnt = 0; m > 0ul; ++cnt) |
60478656 | 49 | { |
dd7d45e8 UD |
50 | result[cnt] = conv_table[m & 0x3f]; |
51 | m >>= 6; | |
60478656 | 52 | } |
ab1c32a6 | 53 | result[cnt] = '\0'; |
60478656 | 54 | |
ab1c32a6 | 55 | return result; |
60478656 | 56 | } |