chiark / gitweb /
agent: Avoid tight timer tick when possible.
[gnupg2.git] / kbx / mkerrors
1 #!/bin/sh
2 # mkerrors - Extract error strings from assuan.h
3 #            and create C source for assuan_strerror
4 #       Copyright (C) 2001 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 mkerrors */
23 /* Do not edit! */
24
25 #include <stdio.h>
26 #include "keybox-defs.h"
27
28 /**
29  * keybox_strerror:
30  * @err:  Error code
31  *
32  * This function returns a textual representaion of the given
33  * errorcode. If this is an unknown value, a string with the value
34  * is returned (Beware: it is hold in a static buffer).
35  *
36  * Return value: String with the error description.
37  **/
38 const char *
39 keybox_strerror (KeyboxError err)
40 {
41   const char *s;
42   static char buf[25];
43
44   switch (err)
45     {
46 EOF
47
48 awk '
49 /KEYBOX_No_Error/    { okay=1 }
50 !okay              {next}
51 /}/                { exit 0 }
52 /KEYBOX_[A-Za-z_]*/ { print_code($1) }
53
54
55 function print_code( s )
56 {
57 printf "    case %s: s=\"", s ;
58 gsub(/_/, " ", s );
59 printf "%s\"; break;\n", tolower(substr(s,8));
60 }
61 '
62
63 cat <<EOF
64     default:  sprintf (buf, "ec=%d", err ); s=buf; break;
65     }
66
67   return s;
68 }
69
70 EOF