OSDN Git Service

Fix no pic
[uclinux-h8/uClinux-dist.git] / user / frob-led / keywords.pl
1 # $Id: keywords.pl,v 1.1 2001-03-23 06:26:00 gerg Exp $
2
3 # Generate keyword tables from ledman.h.
4
5 my @cmds;
6 my @leds;
7
8 while (<>) {
9     if (/^#define\s+LEDMAN_CMD_([A-Z0-9_]+)/) {
10         push @cmds, $1;
11     } elsif (@cmds || /LEDMAN_MAX/) {
12         next;
13     } elsif (/^#define\s+LEDMAN_([A-Z0-9_]+)/) {
14         push @leds, $1;
15     }
16 }
17
18 print <<EOF;
19 typedef struct table {
20   const char *name;
21   unsigned value;
22 } table_t;
23
24 static const table_t cmds[] = {
25 EOF
26
27 print "  { \"$_\", LEDMAN_CMD_$_ },\n"
28     foreach (@cmds);
29
30 print <<EOF;
31   { 0, 0 }
32 };
33
34 static table_t leds[] = {
35 EOF
36
37 print "  { \"$_\", LEDMAN_$_ },\n"
38     foreach (@leds);
39
40 print <<EOF;
41   { 0, 0 }
42 };
43 EOF