1 /* ccache2shishi.c --- Print and convert MIT ccache files.
2 * Copyright (C) 2006 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
34 #include <sys/types.h>
41 # define setlocale(Category, Locale) /* empty */
44 #define _(String) gettext (String)
45 #define gettext_noop(String) String
46 #define N_(String) gettext_noop (String)
50 /* Get set_program_name and program_name. */
56 #include "ccache2shishi_cmd.h"
59 main (int argc
, char *argv
[])
61 struct gengetopt_args_info args
;
67 setlocale (LC_ALL
, "");
68 bindtextdomain (PACKAGE
, LOCALEDIR
);
70 set_program_name (argv
[0]);
72 if (cmdline_parser (argc
, argv
, &args
) != 0)
73 error (EXIT_FAILURE
, 0, _("Try `%s --help' for more information."),
76 if (args
.inputs_num
> 0)
77 infile
= args
.inputs
[0];
79 if (args
.inputs_num
> 1)
80 outfile
= args
.inputs
[1];
82 if (args
.inputs_num
> 2)
84 error (0, 0, _("too many arguments"));
85 error (EXIT_FAILURE
, 0, _("Try `%s --help' for more information."),
91 cmdline_parser_print_help ();
92 printf (_("\nMandatory arguments to long options are "
93 "mandatory for short options too.\n\nReport bugs to <%s>.\n"),
100 error (EXIT_FAILURE
, 0, _("Could not initialize libshishi."));
102 if (args
.verbose_given
> 0)
103 shishi_cfg (sh
, "verbose");
104 if (args
.verbose_given
> 1)
105 shishi_cfg (sh
, "verbose-noise");
106 if (args
.verbose_given
> 2)
107 shishi_cfg (sh
, "verbose-asn1");
108 if (args
.verbose_given
> 3)
109 shishi_cfg (sh
, "verbose-crypto");
110 if (args
.verbose_given
> 4)
111 shishi_cfg (sh
, "verbose-crypto-noise");
114 infile
= shishi_tkts_default_ccache (sh
);
117 outfile
= shishi_tkts_default_file (sh
);
122 rc
= shishi_tkts_from_ccache_file (sh
, infile
, &tkts
);
124 error (EXIT_FAILURE
, errno
, "%s: %s", infile
, shishi_strerror (rc
));
126 if (args
.verbose_given
)
127 shishi_tkts_print (tkts
, stdout
);
129 rc
= shishi_tkts_to_file (tkts
, outfile
);
131 error (EXIT_FAILURE
, errno
, "%s:%s", outfile
, shishi_strerror (rc
));
133 if (!args
.quiet_flag
)
135 size_t ntkts
= shishi_tkts_size (tkts
);
137 printf (_("No tickets written.\n"));
139 printf (ngettext ("%d ticket written.\n",
140 "%d tickets written.\n", ntkts
), ntkts
);
143 shishi_tkts_done (&tkts
);