File: debughash.gperf

package info (click to toggle)
heroes 0.21-21
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,796 kB
  • sloc: ansic: 27,951; sh: 3,941; makefile: 651; yacc: 318; sed: 51; lisp: 10; perl: 9
file content (106 lines) | stat: -rw-r--r-- 3,510 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
%{
/*				 -*- buffer-read-only: t -*- vi: set ro:
** 
** DO NOT EDIT THIS FILE   (src/debughash.gperf)
** 
** It has been AutoGen-ed  Saturday March 30, 2002 at 04:43:41 PM CET
** From the definitions    src/debugchn.def
** and the template file   debugchn
*/

/*
** Heroes is free software.
** 
** You may redistribute it and/or modify it under the terms of the
** GNU General Public License, as published by the Free Software
** Foundation; either version 2, or (at your option) any later version.
** 
** Heroes is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU General Public License for more details.
** 
** You should have received a copy of the GNU General Public License
** along with Heroes.  See the file "COPYING".  If not,
** write to:  The Free Software Foundation, Inc.,
**            59 Temple Place - Suite 330,
**            Boston,  MA  02111-1307, USA.
*/

#include "system.h"
#include "debughash.h"
#include "errors.h"
#include "fstrcmp.h"

/* prototype in_channel_set as static */
static struct debug_channel_s *
in_channel_set (register const char *str, register unsigned int len);
%}
struct debug_channel_s {
  const char *name;
  const char *doc;
  enum debug_lvl number;
};
%%
all,              N_("all messages"),                          -1
section,          N_("different parts of the game"),           D_SECTION
system,           N_("system related messages"),               D_SYSTEM
resource,         N_("filename resources handling"),           D_RESOURCE
file,             N_("files and directories handling"),        D_FILE
level,            N_("levels handling"),                       D_LEVEL
sound_track,      N_("sound track events"),                    D_SOUND_TRACK
sound_effect,     N_("sound effects events"),                  D_SOUND_EFFECT
video,            N_("communication with the display driver"), D_VIDEO
joystick,         N_("joystick initialization and events"),    D_JOYSTICK
timer,            N_("timer handling"),                        D_TIMER
misc,             N_("miscellaneous events"),                  D_MISC
fader,            N_("palette fade events"),                   D_FADER
bonus,            N_("bonus"),                                 D_BONUS
%%
static const struct debug_channel_s *
get_channel_approx (const char *name)
{
  int i;
  const struct debug_channel_s *res = 0;
  double best_weight = 0.7;

  for (i = MIN_HASH_VALUE; i <= MAX_HASH_VALUE; ++i) {
    if (channel_set[i].name[0]) {
      double weight = fstrcmp (name, channel_set[i].name);
      if (weight > best_weight) {
        best_weight = weight;
        res = &(channel_set[i]);
      }
    }
  }
  return res;
}

enum debug_lvl
get_channel_number (const char *name)
{
  const struct debug_channel_s *res = in_channel_set (name, strlen (name));
  if (!res) {
    /* try to find a channel which name is close to the given name */
    res = get_channel_approx (name);
    if (res)
      wmsg (_("%s: no such channel, assuming you meant '%s'."),
            name, res->name);
    else
      emsg (_("%s: no such channel (--list=debug will list "
              "all known channels)"), name);
  }
  return res->number;
}

void
print_debug_channels (void)
{
  int i;
  for (i = MIN_HASH_VALUE; i <= MAX_HASH_VALUE; ++i) {
    if (channel_set[i].name[0]) {
      printf ("%-16s %s\n", channel_set[i].name, _(channel_set[i].doc));
    }
  }
}