Imported Upstream version 2.2.1
[platform/upstream/gpg2.git] / common / mkerrtok
1 #!/bin/sh
2 # mkerrtok - Create error tokens from errors.h
3 #            and the C source for gnupg_errortoken
4 #       Copyright (C) 2001, 2002 Free Software Foundation, Inc.
5 #
6 # This file is part of GnuPG.
7 #
8 # GnuPG is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # GnuPG is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, see <http://www.gnu.org/licenses/>.
20
21 cat <<EOF
22 /* Generated automatically by mkerrtok */
23 /* Do not edit! */
24
25 /**
26  * gnupg_error_token:
27  * @err:  Error code
28  *
29  * This function returns a textual representaion of the given
30  * errorcode. If this is an unknown value, a static string is returned.
31  * This function differs from gnupg_strerror that it yields the string
32  * representation of the macro which is never subject to i18n.
33  *
34  * Return value: String with the error token.
35  **/
36 const char *
37 gnupg_error_token (int err)
38 {
39   const char *s;
40
41   switch (err)
42     {
43 EOF
44
45 awk '
46 /GNUPG_No_Error/  { okay=1 }
47 !okay              {next}
48 /}/                { exit 0 }
49 /GNUPG_[A-Za-z_]*/ { print_code($1) }
50
51
52 function print_code( s )
53 {
54 printf "    case %s: s=\"", s ;
55 printf "%s\"; break;\n", substr(s,7);
56 }
57 '
58
59 cat <<EOF
60     default:  s = "Unknown_Error"; break;
61     }
62
63   return s;
64 }
65
66 EOF