2005-04-15 Marcus Brinkmann <marcus@g10code.de>
[gnupg.git] / kbx / mkerrors
blob5adb7bfdfe3c10960093f0b038d84f0f780b7b69
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.
6 # This file is part of GnuPG.
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 2 of the License, or
11 # (at your option) any later version.
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.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 cat <<EOF
23 /* Generated automatically by mkerrors */
24 /* Do not edit! */
26 #include <stdio.h>
27 #include "keybox-defs.h"
29 /**
30 * keybox_strerror:
31 * @err: Error code
33 * This function returns a textual representaion of the given
34 * errorcode. If this is an unknown value, a string with the value
35 * is returned (Beware: it is hold in a static buffer).
37 * Return value: String with the error description.
38 **/
39 const char *
40 keybox_strerror (KeyboxError err)
42 const char *s;
43 static char buf[25];
45 switch (err)
47 EOF
49 awk '
50 /KEYBOX_No_Error/ { okay=1 }
51 !okay {next}
52 /}/ { exit 0 }
53 /KEYBOX_[A-Za-z_]*/ { print_code($1) }
56 function print_code( s )
58 printf " case %s: s=\"", s ;
59 gsub(/_/, " ", s );
60 printf "%s\"; break;\n", tolower(substr(s,8));
64 cat <<EOF
65 default: sprintf (buf, "ec=%d", err ); s=buf; break;
68 return s;
71 EOF