chiark / gitweb /
can fit 139 lines on an atp -B page
[trains.git] / hostside / errorcodes.h.gen
1 #!/usr/bin/perl
2
3 @f= qw(
4        OK
5        MovFeatTooLate
6        MovFeatKindsCombination
7        MovFeatReservationInapplicable
8        MovFeatRouteNotFound
9        BufferFull
10        BadCmd
11        InvalidState
12        SignallingPredictedProblem
13        SignallingHorizonReached
14        CommandPreconditionsViolated
15
16        LimitExceeded
17        SystemFailed
18        UnknownCommand
19        PermissionDenied
20        HostSupportSystemsProblem
21        );
22
23
24     
25 $decl= "const char *const errorcodelist[]";
26
27 print <<END
28 typedef enum {
29 END
30     ."  ".(join ",\n  ", map {
31         $f=$_; $f =~ s/\-//g; "EC_$f";
32     } @f).<<END
33
34 } ErrorCode;
35
36 extern $decl;
37
38 #define ec2str(ec) (errorcodelist[(ec)])
39
40 #define DEFINE_ERRORCODELIST_DATA \\
41 $decl= { \\
42 END
43     ."  ".(join ", \\\n  ", map {
44         '"'.$_.'"';
45     } @f).<<END
46  \\
47 };
48 END
49     or die $!;