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