~ubuntu-branches/ubuntu/feisty/gnupg2/feisty

« back to all changes in this revision

Viewing changes to common/mkerrors

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-07-11 11:38:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060711113813-zaw7unlbuh7gyxtl
Tags: 1.9.21-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# mkerrors - Extract error strings from errors.h
3
 
#            and create C source for gnupg_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 2 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, write to the Free Software
20
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21
 
 
22
 
cat <<EOF
23
 
/* Generated automatically by mkerrors */
24
 
/* Do not edit! */
25
 
 
26
 
#include <config.h>
27
 
#include <stdio.h>
28
 
#include "errors.h"
29
 
 
30
 
/**
31
 
 * gnupg_strerror:
32
 
 * @err:  Error code 
33
 
 * 
34
 
 * This function returns a textual representaion of the given
35
 
 * errorcode. If this is an unknown value, a string with the value
36
 
 * is returned (Beware: it is hold in a static buffer).
37
 
 * 
38
 
 * Return value: String with the error description.
39
 
 **/
40
 
const char *
41
 
gnupg_strerror (int err)
42
 
{
43
 
  const char *s;
44
 
  static char buf[25];
45
 
 
46
 
  switch (err)
47
 
    {
48
 
EOF
49
 
 
50
 
awk '
51
 
/GNUPG_No_Error/  { okay=1 }
52
 
!okay              {next}
53
 
/}/                { exit 0 }
54
 
/GNUPG_[A-Za-z_]*/ { print_code($1) }
55
 
 
56
 
 
57
 
function print_code( s )
58
 
{
59
 
printf "    case %s: s=\"", s ;
60
 
gsub(/_/, " ", s );
61
 
printf "%s\"; break;\n", tolower(substr(s,7));
62
 
}
63
 
'
64
 
 
65
 
cat <<EOF
66
 
    default:  sprintf (buf, "ec=%d", err ); s=buf; break;
67
 
    }
68
 
 
69
 
  return s;
70
 
}
71
 
 
72
 
EOF
 
 
b'\\ No newline at end of file'