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