~ubuntu-branches/ubuntu/natty/libgpg-error/natty

« back to all changes in this revision

Viewing changes to src/mkerrcodes.awk

  • Committer: Bazaar Package Importer
  • Author(s): Jose Carlos Garcia Sogo
  • Date: 2004-03-16 23:25:13 UTC
  • Revision ID: james.westby@ubuntu.com-20040316232513-u9dnue5r0i3egfkq
Tags: upstream-0.7
ImportĀ upstreamĀ versionĀ 0.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# mkerrcodes.awk
 
2
# Copyright (C) 2004 g10 Code GmbH
 
3
 
4
# This program is free software; you can redistribute it and/or
 
5
# modify it under the terms of the GNU General Public License as
 
6
# published by the Free Software Foundation; either version 2 of
 
7
# the License, or (at your option) any later version.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
# General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 
17
#
 
18
# As a special exception, g10 Code GmbH gives unlimited permission to
 
19
# copy, distribute and modify the C source files that are the output
 
20
# of mkerrcodes.awk.  You need not follow the terms of the GNU General
 
21
# Public License when using or distributing such scripts, even though
 
22
# portions of the text of mkerrcodes.awk appear in them.  The GNU
 
23
# General Public License (GPL) does govern all other use of the material
 
24
# that constitutes the mkerrcodes.awk program.
 
25
#
 
26
# Certain portions of the mkerrcodes.awk source text are designed to be
 
27
# copied (in certain cases, depending on the input) into the output of
 
28
# mkerrcodes.awk.  We call these the "data" portions.  The rest of the
 
29
# mkerrcodes.awk source text consists of comments plus executable code
 
30
# that decides which of the data portions to output in any given case.
 
31
# We call these comments and executable code the "non-data" portions.
 
32
# mkerrcodes.h never copies any of the non-data portions into its output.
 
33
#
 
34
# This special exception to the GPL applies to versions of mkerrcodes.awk
 
35
# released by g10 Code GmbH.  When you make and distribute a modified version
 
36
# of mkerrcodes.awk, you may extend this special exception to the GPL to
 
37
# apply to your modified version as well, *unless* your modified version
 
38
# has the potential to copy into its output some of the text that was the
 
39
# non-data portion of the version that you started with.  (In other words,
 
40
# unless your change moves or copies text from the non-data portions to the
 
41
# data portions.)  If your modification has such potential, you must delete
 
42
# any notice of this special exception to the GPL from your modified version.
 
43
 
 
44
# This script outputs an intermediate file that contains the following block
 
45
# for each error value symbol in the input file (example for EINVAL):
 
46
#
 
47
# #ifdef EINVAL
 
48
# EINVAL GPG_ERR_EINVAL
 
49
# #endif
 
50
#
 
51
# The input file is a list of possible system errors.
 
52
#
 
53
# Comments (starting with # and ending at the end of the line) are removed,
 
54
# as is trailing whitespace.
 
55
 
 
56
BEGIN {
 
57
  FS="[ \t]+GPG_ERR_";
 
58
  print "/* Output of mkerrcodes.awk.  DO NOT EDIT.  */";
 
59
  print "";
 
60
  header = 1;
 
61
}
 
62
 
 
63
/^#/ { next; }
 
64
 
 
65
header {
 
66
  if ($0 ~ /^[0-9]+/)
 
67
    {
 
68
      header = 0;
 
69
 
 
70
      print "static struct";
 
71
      print "  {";
 
72
      print "    int err;";
 
73
      print "    const char *err_sym;";
 
74
      print "  } err_table[] = ";
 
75
      print "{";
 
76
    }
 
77
  else
 
78
    print;
 
79
}
 
80
 
 
81
!header {
 
82
  sub (/\#.+/, "");
 
83
  sub (/[       ]+$/, ""); # Strip trailing space and tab characters.
 
84
 
 
85
  if (/^$/)
 
86
    next;
 
87
 
 
88
    print "  { " $1 ", \"GPG_ERR_" $2 "\" },";
 
89
}
 
90
 
 
91
END {
 
92
  print "};";
 
93
}