| 1627 | } |
| 1628 | |
| 1629 | int |
| 1630 | main (int argc, char **argv) |
| 1631 | { |
| 1632 | int opt; |
| 1633 | FILE *input_fh; |
| 1634 | char const *infile; |
| 1635 | |
| 1636 | /* True if --decode has been given and we should decode data. */ |
| 1637 | bool decode = false; |
| 1638 | /* True if we should ignore non-base-alphabetic characters. */ |
| 1639 | bool ignore_garbage = false; |
| 1640 | /* Wrap encoded data around the 76th column, by default. */ |
| 1641 | idx_t wrap_column = 76; |
| 1642 | |
| 1643 | #if BASE_TYPE == 42 |
| 1644 | int base_type = 0; |
| 1645 | #endif |
| 1646 | |
| 1647 | initialize_main (&argc, &argv); |
| 1648 | set_program_name (argv[0]); |
| 1649 | setlocale (LC_ALL, ""); |
| 1650 | bindtextdomain (PACKAGE, LOCALEDIR); |
| 1651 | textdomain (PACKAGE); |
| 1652 | |
| 1653 | atexit (close_stdout); |
| 1654 | |
| 1655 | while ((opt = getopt_long (argc, argv, "diw:", long_options, NULL)) != -1) |
| 1656 | switch (opt) |
| 1657 | { |
| 1658 | case 'd': |
| 1659 | decode = true; |
| 1660 | break; |
| 1661 | |
| 1662 | case 'w': |
| 1663 | { |
| 1664 | intmax_t w; |
| 1665 | strtol_error s_err = xstrtoimax (optarg, NULL, 10, &w, ""); |
| 1666 | if (LONGINT_OVERFLOW < s_err || w < 0) |
| 1667 | error (EXIT_FAILURE, 0, "%s: %s", |
| 1668 | _("invalid wrap size"), quote (optarg)); |
| 1669 | wrap_column = s_err == LONGINT_OVERFLOW || IDX_MAX < w ? 0 : w; |
| 1670 | } |
| 1671 | break; |
| 1672 | |
| 1673 | case 'i': |
| 1674 | ignore_garbage = true; |
| 1675 | break; |
| 1676 | |
| 1677 | #if BASE_TYPE == 42 |
| 1678 | case BASE64_OPTION: |
| 1679 | case BASE64URL_OPTION: |
| 1680 | case BASE32_OPTION: |
| 1681 | case BASE32HEX_OPTION: |
| 1682 | case BASE16_OPTION: |
| 1683 | case BASE2MSBF_OPTION: |
| 1684 | case BASE2LSBF_OPTION: |
| 1685 | case Z85_OPTION: |
| 1686 | case BASE58_OPTION: |